|
|
Obi adding huge forces to rigidbodies when you delete ropes... (Repro project) |
Posted by: Hatchling - 19-05-2021, 04:49 PM - Forum: Obi Rope
- Replies (8)
|
 |
So, this time I found that when you delete ropes, it can cause NaNs and absurd velocity assignments to rigidbodies when you destroy a rope's GameObject.
The repro package can be found here: (Expires in 30 days)
https://ufile.io/45i4log9
To reproduce:
- Start a new Unity project (I'm using 2020.2.0f1).
- Add Burst (version 1.4.8) and Jobs (version 0.8.0-preview.23) through the Package Manager.
- Import the package linked above.
- Open SampleScene.unity and press Play.
- Click and drag to attach a rope. The point where you click (mouse down) will be the first point where a rope gets attached. The point where you let go (mouse up) will be the second point where a rope gets attached. Add several ropes.
- Press [R] to delete all of the ropes you created.
- Repeat 4 and 5 until the bug is reproduced.
You'll see this when you reproduce the bug:- The rigidbodies in the scene may start behaving abnormally, with ghost forces pushing them around even though all of the ropes have been removed.
- You'll see errors spamming the console regarding invalid forces being applied to one or more of the rigidbodies. For example: rigidbody.velocity assign attempt for 'Floating Platform' is not valid. Input velocity is { 2.468001, NaN, 55.692116 }.
- Some of the rigidbodies may explode into outer space from the absurd forces.
Seems related to the previous bug I posted, with very similar symptoms.
Other symptoms I've noticed in fighting with this bug:- When I start SampleScene with a rope in the scene already, (drag ObiPrefabs/Rope into the scene and activate the GameObject before pressing play) any ropes you add to the scene will be frozen and will not simulate.
- After reproducing the above bug: When switching to the scene "RopeNet" (which uses a modified example script to use the global solver), pressing play, and then unpressing play, the console will spam about some phantom Obi.ObiLateFixedUpdater trying to poke at various destroyed Obi components. When this occurs, you'll find that there are no ObiLateFixedUpdater instances visible in the hierarchy.
Code modifications to note:- ObiStatic.cs added, which enables a global solver.
- ObiStaticSettings.cs added, which allows you to define the global solver using a prefab reference.
- When an ObiRope is created, it will check for a solver in one of its ancestors. If one isn't found, it'll use ObiStatic.WorldSolver, which will get instantiated if needed.
- RopeNet.cs will use ObiStatic.WorldSolver instead of creating its own solver.
|
|
|
How to query Obi geometry with raycasts? |
Posted by: Hatchling - 15-05-2021, 06:57 AM - Forum: Obi Rope
- Replies (15)
|
 |
Does Obi provide the ability to query the geometry of Obi Actors, like how Physics.Raycast, .Spherecast, etc. allows you to query colliders?
I'm assuming that most of the math involved for this has already been done somewhere in there in order to support collision detection.
I see there is ObiParticlePicker, but it seems like this approach isn't optimal:- Only allows picking particles directly, instead of by their collision geometry (simplexes)
- Doesn't return a point on the surface that the ray first made contact
- Doesn't query the particle grid to filter out most of the tests
- Isn't written in efficient threaded code in the same way that other collision checks are
- Only considers one solver
- Cannot be invoked in a static way (like Physics.Raycast)
If I were more familiar with how to interface with the internal stuff of Obi, I'd be willing to write these queries myself. An interesting idea might be to provide some sort of base query class where you can implement custom queries (for example, getting the closest point on a simplex to the query point, within a certain radius (or infinite radius)). If I wrote something like this, I'd be willing to share the code with the hope that it'd be maintained as Obi is developed.
A global query would probably follow this procedure:
- Test the query condition against the oriented bounding box of each solver. If a given solver passes, then...
- Test the query condition against all occupied cells, OR, in cases where it is possible to determine which cells pass the query condition without enumerating through each cell, get a list of cells that pass the query condition. If a given cell passes, then...
- Test the query condition against all simplexes occupying the cell.
- For each simplex that passes the query condition, modify the query result.
- In the case of a Raycast, replace the current hit point if its distance from the ray is closer.
- In the case of a RaycastAll, add the hit point to the list of hit points.
- In the case of a Checksphere (which returns true if any object occupies a spherical volume, otherwise false), terminate the query and return "true" as the query result if and when a simplex passes the query condition, otherwise false. (A similar test could be done on the cell/solver bounding box itself if it is fully contained within the Checksphere volume.)
A solver specific query would be similar, sans step 1.
I'm guessing that it'd be wasteful to redo all of the work involved in calculating queries like these, given that collision tests between line simplexes and other types are already possible. (A line simplex can be treated like a raycast or a spherecast, with minor modifications.)
|
|
|
How does one disable "phase" based collision masking? |
Posted by: Hatchling - 15-05-2021, 01:57 AM - Forum: Obi Rope
- Replies (6)
|
 |
I'd like to ensure that, in my project, everything is able to collide with everything else. However, each time I instantiate a rope, it has the same phase as the last rope I instantiated.
I'd like to disable this feature, as going in and editing each rope I instantiate to have a unique phase seems like it'd be a real pain.
Is there a way to do this? Or would I need to modify source code I don't have access to (e.g. in the DLL)?
EDIT: It appears that using self-collision doesn't just allow collision with the self, but also allows collision between *everything else* of the same phase, *except* rigidbodies, which mostly solves the problem: Just make sure everything has "Self Collision" enabled and that every particle actor uses phase 1, and every rigidbody uses phase 0.
The description is a bit misleading. (Also, as a side note, the term "phase" doesn't evoke the concept of collision. Usually phase is used to describe something's progress through a cycle, like rotation. Perhaps "layer" would be a better term.)
|
|
|
softBody velocity |
Posted by: ReaperQc - 14-05-2021, 02:17 AM - Forum: Obi Softbody
- Replies (5)
|
 |
Hi, I am trying to get access to the velocity of my softbody because i can switch between multiple character with different controls. some use rigidbody and one use the softbody, when i switch from the rigidbody to the softbody, i can apply a force to the softbody that is the same as the last velocity of my rigidbody before switching, but when i try to switch from the softbody to a rigidbody, i would like to get the last velocity of my softbody and apply it to the rigidbody's velocity, but unfortunately,I am unsure where to access the softbody's velocity, i was able to find the solver's velocities but it return an unusable vector4 that is only usable with obi element.
|
|
|
Tear after changing length with cursor |
Posted by: luvjungle - 13-05-2021, 02:37 PM - Forum: Obi Rope
- Replies (5)
|
 |
Hi all!
Is it possible to tear after changing length?
Here is my code for tearing:
Code: void Solver_OnCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
{
var world = ObiColliderWorld.GetInstance();
// just iterate over all contacts in the current frame:
foreach (Oni.Contact contact in e.contacts)
{
// if this one is an actual collision:
if (contact.distance > 0.01) continue;
ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
TearRope(col, contact);
}
}
private void TearRope(ObiColliderBase col, Oni.Contact contact)
{
if (!col || !col.CompareTag(StaticData.tear)) return;
ObiSolver.ParticleInActor pa = solver.particleToActor[contact.bodyA];
if (pa == null) return;
var actor = pa.actor as ObiRope;
if (!actor) return;
if (pa.indexInActor >= actor.elements.Count) return;
actor.Tear(actor.elements[pa.indexInActor]);
actor.RebuildConstraintsFromElements();
}
It works for pre-created rope, but when I change length, it cuts somewhere at the end, not at collision point.
Please help.
|
|
|
Export Obi Cloth Simulation as Alembic File |
Posted by: orestissar - 13-05-2021, 01:28 PM - Forum: Obi Cloth
- Replies (7)
|
 |
Hello there,
I have a scene with a human avatar wearing a shirt(the garment is divided in separate parts like: front/back torso, sleeves etc). I have succesfully created (you helped me in another thread !) a script that creates all obi components and adds them to the Shirt.
Everything is working fine so far.
Using the Alembic library from the package manager, im able to export the scene into an alembic format.
However, when i load and play the new alembic object in the scene the shirt dissapears in the alembic animation after a while. I tried to export the same avatar/shirt before adding the OBI components and in this case the alembic animation works fine. What i mean is that when the shirt is OBI, it dissapears from the alembic.
Do you possibly have any idea/solution of why this happens?
Thanks a lot beforehand!
|
|
|
Deactivating the obi solver when not needed ? |
Posted by: VincentAbert - 13-05-2021, 01:07 PM - Forum: Obi Rope
- Replies (12)
|
 |
Hello,
Let's say I have a level which only features ropes in one or two rooms. Trying to mitigate all my performance overhead, I would like to disable simulation when not needed, what is the best way to do that ?
I tried disabling the updater and solver, and activating them when the player enters a trigger, but it causes a lag spike, probably because of some initialization. What would be the best way to go about this ?
Thank you,
Vincent.
|
|
|
|