fix big number raycast hit cout

This commit is contained in:
2016-11-30 01:29:27 +07:00
parent eb533aa868
commit ef85079c64

View File

@@ -52,11 +52,17 @@ namespace IsoTools.Physics {
int layer_mask = UnityEngine.Physics.DefaultRaycastLayers, int layer_mask = UnityEngine.Physics.DefaultRaycastLayers,
QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal) QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
{ {
do {
var hit_count = UnityEngine.Physics.RaycastNonAlloc(ray, _raycastNonAllocBuffer, var hit_count = UnityEngine.Physics.RaycastNonAlloc(ray, _raycastNonAllocBuffer,
max_distance, max_distance,
layer_mask, layer_mask,
query_trigger_interaction); query_trigger_interaction);
if ( hit_count >= results.Length || hit_count < _raycastNonAllocBuffer.Length ) {
return RaycastBufferToIsoRaycastHits(hit_count, results); return RaycastBufferToIsoRaycastHits(hit_count, results);
} else {
_raycastNonAllocBuffer = new RaycastHit[_raycastNonAllocBuffer.Length * 2];
}
} while ( true );
} }
// //
@@ -247,12 +253,18 @@ namespace IsoTools.Physics {
int layer_mask = UnityEngine.Physics.AllLayers, int layer_mask = UnityEngine.Physics.AllLayers,
QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal) QueryTriggerInteraction query_trigger_interaction = QueryTriggerInteraction.UseGlobal)
{ {
do {
var collider_count = UnityEngine.Physics.OverlapBoxNonAlloc( var collider_count = UnityEngine.Physics.OverlapBoxNonAlloc(
center, half_extents, _overlapNonAllocBuffer, center, half_extents, _overlapNonAllocBuffer,
Quaternion.identity, Quaternion.identity,
layer_mask, layer_mask,
query_trigger_interaction); query_trigger_interaction);
if ( collider_count >= results.Length || collider_count < _overlapNonAllocBuffer.Length ) {
return OverlapBufferToIsoColliders(collider_count, results); return OverlapBufferToIsoColliders(collider_count, results);
} else {
_overlapNonAllocBuffer = new Collider[_overlapNonAllocBuffer.Length * 2];
}
} while ( true );
} }
// //