Skip to content

Commit ac9c007

Browse files
committed
feat: minimizing repeat calls to WarpBrain
1 parent 75ce88b commit ac9c007

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.44912726, g: 0.49919963, b: 0.5757154, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44824904, g: 0.49827605, b: 0.5755831, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:

Assets/Scripts/Pinpoint/PinpointAtlasManager.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,27 +154,44 @@ private string ConverTransform2UserFriendly(string transformName)
154154
return $"Atlas transform: {transformName}";
155155
}
156156

157-
#endregion
157+
#endregion
158158

159159

160-
#region Warping
160+
#region Warping
161+
Vector3 _activeWarp;
161162

162163
public void WarpBrain()
163164
{
165+
#if UNITY_EDITOR
166+
Debug.Log("(PAM) Warp brain called");
167+
#endif
168+
Vector3 newWarp = WorldU2WorldT_Wrapper(Vector3.one);
169+
170+
// Check if the brain actually needs to be warped
171+
if (newWarp == _activeWarp)
172+
{
173+
#if UNITY_EDITOR
174+
Debug.Log("(PAM) Active warp matches: saving time by skipping");
175+
#endif
176+
return;
177+
}
178+
179+
_activeWarp = newWarp;
180+
164181
foreach (OntologyNode node in DefaultNodes)
165-
WarpNode(node);
182+
WarpNode(node, WorldU2WorldT_Wrapper);
166183
}
167184

168-
public void WarpNode(OntologyNode node)
185+
public void WarpNode(OntologyNode node, Func<Vector3, Vector3> warpFunction)
169186
{
170-
node.ApplyAtlasTransform(WorldU2WorldT_Wrapper);
187+
node.ApplyAtlasTransform(warpFunction);
171188
}
172189

173190
public void UnwarpBrain()
174191
{
175192
foreach (OntologyNode node in DefaultNodes)
176193
{
177-
node.ApplyAtlasTransform(WorldU2WorldT_Wrapper);
194+
node.ResetAtlasTransform();
178195
}
179196
}
180197

0 commit comments

Comments
 (0)