26-11-2023, 08:58 PM
(This post was last modified: 27-11-2023, 08:22 AM by josemendez.)
(26-11-2023, 05:01 PM)KBTIT_ Wrote: Thank you for your response.
I tried using Softbody.Teleport() and confirmed that Softbody starts moving mysteriously unless all of the Quaternion rotation is 0.
The Gravity in Obi Solver is all 0.
Hi,
I’m unable to reproduce this, Teleport() only changes particle positions. It will not affect velocities, so if particles weren’t moving before being teleported, they shouldn’t move after.
After testing this is multiple settings, I've discovered a regression bug in ObiSoftbody's implementation of Teleport in the latest version that introduces rotational energy when using a non-unit quaternion, just like you described. Here's a corrected version, replace the Teleport() function in Obi/Scripts/Softbody/Actors/ObiSoftbody.cs with this one:
Code:
public override void Teleport(Vector3 position, Quaternion rotation)
{
if (!isLoaded)
return;
Matrix4x4 offset = solver.transform.worldToLocalMatrix *
Matrix4x4.TRS(position, Quaternion.identity, Vector3.one) *
Matrix4x4.TRS(Vector3.zero, rotation, Vector3.one) *
Matrix4x4.TRS(Vector3.zero, Quaternion.Inverse(transform.rotation), Vector3.one) *
Matrix4x4.TRS(-transform.position, Quaternion.identity, Vector3.one) *
solver.transform.localToWorldMatrix;
Quaternion rotOffset = offset.rotation;
base.Teleport(position, rotation);
var ac = GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
var sc = solver.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
// rotate clusters accordingly:
for (int i = 0; i < ac.GetBatchCount(); ++i)
{
int batchOffset = solverBatchOffsets[(int)Oni.ConstraintType.ShapeMatching][i];
for (int j = 0; j < ac.batches[i].activeConstraintCount; ++j)
{
sc.batches[i].orientations[batchOffset + j] = rotOffset * sc.batches[i].orientations[batchOffset + j];
}
}
}
Quote:The object to which the Obi Collider is attached does not exist in the scene.
Not sure what you mean by this. If the object does not exist, how can it have a component (ObiCollider) attached to it? What does this have to do with the Teleport() problem?
kind regards,