public void AddRigidDynamic(PxGhRigidDynamic o) { ghPxRigidDynamics.AddLast(o); PhysXManager.Scene.AddActor(o.actor); }
public void RemoveRigidDynamic(PxGhRigidDynamic o) { ghPxRigidDynamics.Remove(o); PhysXManager.Scene.RemoveActor(o.actor); }
protected override void SolveInstance(IGH_DataAccess DA) { Vector3d iGravity = Vector3d.Unset; double iTimestep = double.NaN; int iSteps = 10; bool iReset = false; bool iRun = false; DA.GetData("Gravity", ref iGravity); DA.GetData("Timestep", ref iTimestep); DA.GetData("Steps", ref iSteps); DA.GetData("Reset", ref iReset); DA.GetData("Run", ref iRun); if (iReset || system == null) { system = new GhPxSystem(); List <PxGhRigidBody> iRigidBodies = new List <PxGhRigidBody>(); foreach (GH_ObjectWrapper flatten in Params.Input[0].VolatileData.AllData(true)) { iRigidBodies.Add((PxGhRigidBody)flatten.Value); } foreach (PxGhRigidBody o in iRigidBodies) { if (o is PxGhRigidDynamic) { PxGhRigidDynamic d = o as PxGhRigidDynamic; system.AddRigidDynamic(d); d.Reset(); } else if (o is PxGhRigidStatic) { PxGhRigidStatic s = o as PxGhRigidStatic; system.AddRigidStatic(s); } } staticGhMeshes = system.GetRigidStaticDisplayGhMeshes(); } if (iRun) { ExpireSolution(true); } stopwatch.Restart(); system.Gravity = iGravity; system.Update((float)iTimestep, iSteps); stopwatch.Stop(); string info = ""; foreach (var o in system.ghPxRigidDynamics) { info += "\n" + o.actor.IsSleeping; } DA.SetData("Info", decimal.Round((decimal)stopwatch.Elapsed.TotalMilliseconds, 2) + "ms" + info); DA.SetDataList("Statics", staticGhMeshes); DA.SetDataList("Dynamics", system.GetRigidDynamicDisplayGhMeshes()); }