UDestructibleComponent::LineTraceComponent possible issue


It seems there is a bug in UDestructibleComponent::LineTraceComponent in this line:

if (ChunkIdx != NxModuleDestructibleConst::INVALID_CHUNK_INDEX && HitTime <= 1.0f)

I’m standing aproximately 0.3m from the destructible and i;m tracing UDestructibleComponent with LineTraceComponent

and if trace succeded the HitTime is greater than 1.f(18.f <=> 30.f). It seems HitTime is distance between start and hit position, not alpha between start position and end position.

If trace failed the ChunkIdx = -1 and HitTime = 0.f

I think the condition should be changed to:

if (ChunkIdx != NxModuleDestructibleConst::INVALID_CHUNK_INDEX)

Take a look on the UDestructibleComponent::SweepComponent too, same condition is there.

Am I right?

My engine version is compiled 4.4.0.



Hi Pierdek,

If the trace succeeds and returns a HitTime > 1 then it looks like a bug on APEX. I’ll take a look and see if I can repro this. It’s possible the API comments are wrong, in which case your fix seems valid, but I want to double check this as it seems like a mistake.

Thanks for the heads up

It turns out in the destruction rayCast PhysX actually expects a non-normalized direction vector which it uses for the distance. The fix is to remove normalization.

I’m going to submit the change later, but for now simply replace this:

int32 ChunkIdx = ApexDestructibleActor->rayCast(HitTime, HitNormal, U2PVector(Start), U2PVector((End-Start).SafeNormal()), NxDestructibleActorRaycastFlags::AllChunks);

with this:

		int32 ChunkIdx = ApexDestructibleActor->rayCast(HitTime, HitNormal, U2PVector(Start), U2PVector(End-Start), NxDestructibleActorRaycastFlags::AllChunks);

Thanks again, let me know if you run into any more trouble