Hi,
Please check this video. when a shape with obicollider collides with the rope, rope goes inside the table ignoring collision.
Shape ObiCollider rigidbody has constraints x and z rotation locked and y position locked. Attached rigidbody, collider, solver and rope config snapshots.
// Setup a blueprint for the rope:
var blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
blueprint.resolution = 0.65f;
blueprint.thickness = 0.07f;
blueprint.pooledParticles = 5;
Vector3 point = Vector3.zero;
blueprint.path.Clear();
int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
float mass = 1;
for (int i = 0; i < points.Length; i++)
{
if (i == 0 || i == points.Length - 1)
{
mass = .001f;
filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 2);
}
else
{
mass = .002f;
filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
}
if( i == 0 )
{
point = rope.transform.InverseTransformPoint(points[i].position);
blueprint.path.AddControlPoint(point, -Vector3.zero, Vector3.zero, Vector3.up, mass, 0.5f, 1, filter, Color.white, "A");
continue;
}
// convert both points to the rope's local space:
/*pointA = rope.transform.InverseTransformPoint(pointA);
pointB = rope.transform.InverseTransformPoint(pointB);
// access the distance constraints currently simulated by the solver:
var solverConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Distance)
as ObiConstraints<ObiDistanceConstraintsBatch>;
int batches = solverConstraints.batches.Count;
for (int k = 0; k < batches; k++)
{
int cnt = solverConstraints.batches[k].constraintCount;
for (int i = 0; i < cnt; i++)
{
solverConstraints.batches[k].restLengths[i] = length;
}
}
Once a cursor is added to a rope (and the length is altered) it looks like the index of the particles no longer returns in a nice order using the below method:
Code:
// first particle in the rope is the first particle of the first element:
int firstParticle = rope.elements[0].particle1;
// last particle in the rope is the second particle of the last element:
int lastParticle = rope.elements[rope.elements.Count-1].particle2;
// now get their positions (expressed in solver space):
var firstPos = rope.solver.positions[firstParticle];
var lastPos = rope.solver.positions[lastParticle];
Instead, I have found I'll get the index of the first particle correct, and the last particle index will be at the first cursor spawn position, and then after that, I can't spy an order to the particles.
I'm using two cursors both facing inward in case that context matters, though I've found the same issue with just one cursor in the crane demo scene also.
Any clues/advice from folks for how to get a nice ordered index of them?
I've been working on a caving simulator for some time now. Obi has become an integral part to get rope climbing, guidelines and hoses interactive! It's incredible what it can do :O
I'm seeing some performance issues from the high fidelity of the rope, but hopefully the new GPU accelerated version can improve on that!
I've set up Obi solver to Use Burst, I have a TONE of work for it - the game is running at 1 FPS in editor, but when I go to Profiler, it shows fully occupied main thread with ObiFixedUpdater.FixedUpdate() while every Job.Worker thread is Idle
Have I made a mistake somewhere?
Seeing this exception when debugging in visual studio,
System.ObjectDisposedException: The UNKNOWN_OBJECT_TYPE has been deallocated, it is not allowed to access it
at (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow_Injected(Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle&)
at Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) [0x00000] in <0652bf0e14024522b5c92574ad0ef550>:0
at Obi.ObiNativeList`1[T].Dispose (System.Boolean disposing) [0x0003d] in C:\Users\bugbe\SpinnyWheels\Assets\Obi\Scripts\Common\DataStructures\NativeList\ObiNativeList.cs:110
at Obi.ObiNativeList`1[T].Finalize () [0x00002] in C:\Users\bugbe\SpinnyWheels\Assets\Obi\Scripts\Common\DataStructures\NativeList\ObiNativeList.cs:90
Hi,
Is it possible to find if there is any rope exists on mouse clicked position ?
something like Physics.OverlapSphere() by passing position and collision radius ?
I'd appreciate some quick advice re: whether there's a more performant way to accomplish what I'm trying to do OOTB. For a first-person "grabbing" system I need to get the particle and related Actor (specifically softbody, but right now code works w/ all actors) closest to an origin point with a given ray.
My current code (adapted crudely from the particle picker example scripts) works, but as it's iterating through A) all particle positions and then B) an undetermined number of softbodies and each of their particles again to relate the particle to an Actor, it's quite inefficient, as I may need many softbodies as well as non-softbody particles in my scenes.
If there are cached bounds/extents per Obi actor I could cluster them into volumes, cast the ray through volumes, and then only iterate over each of their particles, but if those structures exist in ObiActor I can't seem to locate them.
Appreciate any help, thanks!
Code:
public ObiActor GetActor(ObiSolver solver, int particleIndex){
foreach (ObiActor actor in solver.actors){
for (int i = 0; i < actor.solverIndices.count; i++){
if (actor.solverIndices[i] == particleIndex){
return actor;
}
}
}
return null;
}
public int Raycast(ObiSolver solver, Ray ray, float radiusScale, float maxDistance, Vector3 origin){
if (solver == null) return 1;
I am working on a VR project where I need to grab a towel using a controller and then fold and unfold it, as well as rub the cloth on other objects with collision.
Could you please suggest possible ways to achieve the above simulation?