@@ -23,8 +23,6 @@ parameters -> camel_case
2323*/
2424
2525
26- typedef common_utils::Utils Utils;
27-
2826bool UAirBlueprintLib::log_messages_hidden = false ;
2927
3028void UAirBlueprintLib::LogMessageString (const std::string &prefix, const std::string &suffix, LogDebugLevel level, float persist_sec)
@@ -129,12 +127,11 @@ void UAirBlueprintLib::FindAllActor(const UObject* context, TArray<AActor*>& fou
129127}
130128
131129template <typename T>
132- void UAirBlueprintLib::InitializeObjectStencilID (T* mesh)
130+ void UAirBlueprintLib::InitializeObjectStencilID (T* mesh, bool ignore_existing )
133131{
134- // mesh->SetRenderCustomDepth(true);
135132 std::string mesh_name = GetMeshName (mesh);
136- if (mesh_name == " " ) {
137- // Utils::DebugBreak();
133+ if (mesh_name == " " || common_utils::Utils::startsWith (mesh_name, " Default_ " ) ) {
134+ // common_utils:: Utils::DebugBreak();
138135 return ;
139136 }
140137 FString name (mesh_name.c_str ());
@@ -145,11 +142,24 @@ void UAirBlueprintLib::InitializeObjectStencilID(T* mesh)
145142 for (int idx = 0 ; idx < max_len; ++idx) {
146143 hash += UKismetStringLibrary::GetCharacterAsNumber (name, idx);
147144 }
148- // if (mesh->CustomDepthStencilValue == 0) { //if value is already set then don't bother
149- mesh->CustomDepthStencilValue = hash % 256 ;
150- // mesh->SetRenderCustomDepth(true);
151- // mesh->MarkRenderStateDirty();
152- // }
145+ if (ignore_existing || mesh->CustomDepthStencilValue == 0 ) { // if value is already set then don't bother
146+ SetObjectStencilID (mesh, hash % 256 );
147+ }
148+ }
149+
150+ template <typename T>
151+ void UAirBlueprintLib::SetObjectStencilID (T* mesh, int object_id)
152+ {
153+ mesh->SetCustomDepthStencilValue (object_id);
154+ mesh->SetRenderCustomDepth (true );
155+ // mesh->SetVisibility(false);
156+ // mesh->SetVisibility(true);
157+ }
158+
159+ void UAirBlueprintLib::SetObjectStencilID (ALandscapeProxy* mesh, int object_id)
160+ {
161+ mesh->CustomDepthStencilValue = object_id;
162+ mesh->bRenderCustomDepth = true ;
153163}
154164
155165template <class T >
@@ -161,7 +171,7 @@ std::string UAirBlueprintLib::GetMeshName(T* mesh)
161171 return " " ; // std::string(TCHAR_TO_UTF8(*(UKismetSystemLibrary::GetDisplayName(mesh))));
162172}
163173
164- std::string GetMeshName (ALandscapeProxy* mesh)
174+ std::string UAirBlueprintLib:: GetMeshName (ALandscapeProxy* mesh)
165175{
166176 return std::string (TCHAR_TO_UTF8 (*(mesh->GetName ())));
167177}
@@ -183,7 +193,7 @@ void UAirBlueprintLib::InitializeMeshStencilIDs()
183193}
184194
185195template <typename T>
186- void UAirBlueprintLib::SetObjectStencilID (T* mesh, int object_id, const std::string& mesh_name, bool is_name_regex,
196+ void UAirBlueprintLib::SetObjectStencilIDIfMatch (T* mesh, int object_id, const std::string& mesh_name, bool is_name_regex,
187197 const std::regex& name_regex, int & changes)
188198{
189199 std::string comp_mesh_name = GetMeshName (mesh);
@@ -193,11 +203,7 @@ void UAirBlueprintLib::SetObjectStencilID(T* mesh, int object_id, const std::str
193203 || (is_name_regex && std::regex_match (comp_mesh_name, name_regex));
194204 if (is_match) {
195205 ++changes;
196- mesh->CustomDepthStencilValue = object_id;
197- // mesh->SetRenderCustomDepth(false);
198- // mesh->SetRenderCustomDepth(true);
199- // mesh->SetVisibility(false);
200- // mesh->SetVisibility(true);
206+ SetObjectStencilID (mesh, object_id);
201207 }
202208}
203209bool UAirBlueprintLib::SetMeshStencilID (const std::string& mesh_name, int object_id,
@@ -211,11 +217,11 @@ bool UAirBlueprintLib::SetMeshStencilID(const std::string& mesh_name, int object
211217 int changes = 0 ;
212218 for (TObjectIterator<UMeshComponent> comp; comp; ++comp)
213219 {
214- SetObjectStencilID (*comp, object_id, mesh_name, is_name_regex, name_regex, changes);
220+ SetObjectStencilIDIfMatch (*comp, object_id, mesh_name, is_name_regex, name_regex, changes);
215221 }
216222 for (TObjectIterator<ALandscapeProxy> comp; comp; ++comp)
217223 {
218- SetObjectStencilID (*comp, object_id, mesh_name, is_name_regex, name_regex, changes);
224+ SetObjectStencilIDIfMatch (*comp, object_id, mesh_name, is_name_regex, name_regex, changes);
219225 }
220226
221227 return changes > 0 ;
@@ -300,7 +306,7 @@ void UAirBlueprintLib::FollowActor(AActor* follower, const AActor* followee, con
300306 float dist = (follower->GetActorLocation () - next_location).Size ();
301307 float offset_dist = offset.Size ();
302308 float dist_offset = (dist - offset_dist) / offset_dist;
303- float lerp_alpha = Utils::clip ((dist_offset*dist_offset) * 0 .01f + 0 .01f , 0 .0f , 1 .0f );
309+ float lerp_alpha = common_utils:: Utils::clip ((dist_offset*dist_offset) * 0 .01f + 0 .01f , 0 .0f , 1 .0f );
304310 next_location = FMath::Lerp (follower->GetActorLocation (), next_location, lerp_alpha);
305311 follower->SetActorLocation (next_location);
306312
0 commit comments