24-02-2023, 08:21 PM
I still cant get it to render the rope! I have modified the AllocateRawChunks and the PathFrameFromParticle function to use an array of rigidbodies like you said.
I think the issue may be that I must call one of the functions in the pathsmootherscript manually? Because non of them gets ever called (Except for the onEnable/onDisable when I enable/disable the script)
This is what the two functions looks like now
Maybe I also have to modify the for loops that call the PathFrameFromParticle function?
I think the issue may be that I must call one of the functions in the pathsmootherscript manually? Because non of them gets ever called (Except for the onEnable/onDisable when I enable/disable the script)
This is what the two functions looks like now
Code:
private void AllocateRawChunks(Rigidbody[] positions)
{
using (m_AllocateRawChunksPerfMarker.Auto())
{
rawChunks.Clear();
AllocateChunk(positions.Length);
}
}
private void PathFrameFromParticle(ObiRopeBase actor, ref ObiPathFrame frame, int particleIndex, bool interpolateOrientation = true)
{
// Update current frame values from particles:
//frame.position = w2l.MultiplyPoint3x4(actor.GetParticlePosition(particleIndex));
frame.position = ropePositions[particleIndex].worldCenterOfMass;
//frame.thickness = actor.GetParticleMaxRadius(particleIndex);
frame.thickness = 0.1f;
//frame.color = actor.GetParticleColor(particleIndex);
frame.color = Color.red;
// Use particle orientation if possible:
if (actor.usesOrientedParticles)
{
//Quaternion current = actor.GetParticleOrientation(particleIndex);
Quaternion current = ropePositions[particleIndex].rotation;
//Quaternion previous = actor.GetParticleOrientation(Mathf.Max(0, particleIndex - 1));
Quaternion previous = ropePositions[Mathf.Max(0, particleIndex - 1)].rotation;
Quaternion average = w2lRotation * (interpolateOrientation ? Quaternion.SlerpUnclamped(current, previous, 0.5f) : current);
frame.normal = average * Vector3.up;
frame.binormal = average * Vector3.right;
frame.tangent = average * Vector3.forward;
}
}