Skip to content

Commit 6f759e2

Browse files
author
Chris Elion
authored
remove deprecated RayPerceptionMB, legacy codepath: (#3304)
1 parent 59ca276 commit 6f759e2

File tree

7 files changed

+4
-176
lines changed

7 files changed

+4
-176
lines changed

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception2D.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception2D.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public int Write(WriteAdapter adapter)
100100
{
101101
PerceiveStatic(
102102
m_RayDistance, m_Angles, m_DetectableObjects, m_StartOffset, m_EndOffset,
103-
m_CastRadius, m_Transform, m_CastType, m_Observations, false, m_LayerMask,
103+
m_CastRadius, m_Transform, m_CastType, m_Observations, m_LayerMask,
104104
m_DebugDisplayInfo
105105
);
106106
adapter.AddRange(m_Observations);
@@ -144,10 +144,6 @@ public virtual SensorCompressionType GetCompressionType()
144144
/// 3. The 'length+1' element of the sublist will contain the normalised distance to the object hit, or 1 if
145145
/// nothing was hit.
146146
///
147-
/// The legacyHitFractionBehavior changes the behavior to be backwards compatible but has some
148-
/// counter-intuitive behavior:
149-
/// * if the cast hits a object that's not in the detectableObjects list, all results are 0
150-
/// * if the cast doesn't hit, the hit fraction field is 0
151147
/// </summary>
152148
/// <param name="rayLength"></param>
153149
/// <param name="rayAngles">List of angles (in degrees) used to define the rays. 90 degrees is considered
@@ -160,14 +156,12 @@ public virtual SensorCompressionType GetCompressionType()
160156
/// <param name="transform">Transform of the GameObject</param>
161157
/// <param name="castType">Whether to perform the casts in 2D or 3D.</param>
162158
/// <param name="perceptionBuffer">Output array of floats. Must be (num rays) * (num tags + 2) in size.</param>
163-
/// <param name="legacyHitFractionBehavior">Whether to use the legacy behavior for hit fractions.</param>
164159
/// <param name="debugInfo">Optional debug information output, only used by RayPerceptionSensor.</param>
165160
///
166161
public static void PerceiveStatic(float rayLength,
167162
IReadOnlyList<float> rayAngles, IReadOnlyList<string> detectableObjects,
168163
float startOffset, float endOffset, float castRadius,
169164
Transform transform, CastType castType, float[] perceptionBuffer,
170-
bool legacyHitFractionBehavior = false,
171165
int layerMask = Physics.DefaultRaycastLayers,
172166
DebugDisplayInfo debugInfo = null)
173167
{
@@ -212,10 +206,6 @@ public static void PerceiveStatic(float rayLength,
212206
// sublist[numObjects-1] <- did hit detectableObjects[numObjects-1]
213207
// sublist[numObjects ] <- 1 if missed else 0
214208
// sublist[numObjects+1] <- hit fraction (or 1 if no hit)
215-
// The legacyHitFractionBehavior changes the behavior to be backwards compatible but has some
216-
// counter-intuitive behavior:
217-
// * if the cast hits a object that's not in the detectableObjects list, all results are 0
218-
// * if the cast doesn't hit, the hit fraction field is 0
219209

220210
bool castHit;
221211
float hitFraction;
@@ -285,7 +275,7 @@ public static void PerceiveStatic(float rayLength,
285275
}
286276
}
287277

288-
if (!hitTaggedObject && !legacyHitFractionBehavior)
278+
if (!hitTaggedObject)
289279
{
290280
// Something was hit but not on the list. Still set the hit fraction.
291281
perceptionBuffer[bufferOffset + detectableObjects.Count + 1] = hitFraction;
@@ -294,11 +284,8 @@ public static void PerceiveStatic(float rayLength,
294284
else
295285
{
296286
perceptionBuffer[bufferOffset + detectableObjects.Count] = 1f;
297-
if (!legacyHitFractionBehavior)
298-
{
299-
// Nothing was hit, so there's full clearance in front of the agent.
300-
perceptionBuffer[bufferOffset + detectableObjects.Count + 1] = 1.0f;
301-
}
287+
// Nothing was hit, so there's full clearance in front of the agent.
288+
perceptionBuffer[bufferOffset + detectableObjects.Count + 1] = 1.0f;
302289
}
303290

304291
bufferOffset += detectableObjects.Count + 2;

0 commit comments

Comments
 (0)