public AuroraODEPrim(String primName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Vector3 size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, float Density) { m_vehicle = new AuroraODEDynamics(); //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); ode = dode; if (!pos.IsFinite()) { pos = new Vector3((parent_scene.Region.RegionSizeX * 0.5f), (parent_scene.Region.RegionSizeY * 0.5f), parent_scene.GetTerrainHeightAtXY((parent_scene.Region.RegionSizeX * 0.5f), (parent_scene.Region.RegionSizeY * 0.5f))); m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); } _position = pos; fakepos = false; PID_D = parent_scene.bodyPIDD; PID_G = parent_scene.bodyPIDG; // correct for changed timestep PID_D /= (parent_scene.ODE_STEPSIZE * 50f); // original ode fps of 50 PID_G /= (parent_scene.ODE_STEPSIZE * 50f); m_density = Density / 100; // m_tensor = parent_scene.bodyMotorJointMaxforceTensor; body_autodisable_frames = parent_scene.bodyFramesAutoDisable; prim_geom = IntPtr.Zero; prev_geom = IntPtr.Zero; if (!size.IsFinite()) { size = new Vector3(0.5f, 0.5f, 0.5f); m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); } if (size.X <= 0) size.X = 0.01f; if (size.Y <= 0) size.Y = 0.01f; if (size.Z <= 0) size.Z = 0.01f; _size = size; if (!QuaternionIsFinite(rotation)) { rotation = Quaternion.Identity; m_log.Warn("[PHYSICS]: Got nonFinite Object create Rotation"); } _orientation = rotation; fakeori = false; _mesh = mesh; _pbs = pbs; _parent_scene = parent_scene; m_targetSpace = (IntPtr)0; if (pos.Z < 0) m_isphysical = false; else { m_isphysical = pisPhysical; // If we're physical, we need to be in the master space for now. // linksets *should* be in a space together.. but are not currently if (m_isphysical) m_targetSpace = _parent_scene.space; } m_primName = primName; m_forceacc = Vector3.Zero; m_angularforceacc = Vector3.Zero; m_UpdateTimecntr = 0; m_UpdateFPScntr = 2.5f * parent_scene.StepTime; // this parameter needs retunning and possible came from ini file if (m_UpdateTimecntr > .1f) // try to keep it under 100ms m_UpdateTimecntr = .1f; AddChange(changes.Add, null); }
public AuroraODEPrim(String primName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Vector3 size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) { m_vehicle = new AuroraODEDynamics(); //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); ode = dode; if (!pos.IsFinite()) { pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f); m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); } _position = pos; m_taintposition = pos; PID_D = parent_scene.bodyPIDD; PID_G = parent_scene.bodyPIDG; m_density = parent_scene.geomDefaultDensity; // m_tensor = parent_scene.bodyMotorJointMaxforceTensor; body_autodisable_frames = parent_scene.bodyFramesAutoDisable; prim_geom = IntPtr.Zero; prev_geom = IntPtr.Zero; if (!pos.IsFinite()) { size = new Vector3(0.5f, 0.5f, 0.5f); m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); } if (size.X <= 0) size.X = 0.01f; if (size.Y <= 0) size.Y = 0.01f; if (size.Z <= 0) size.Z = 0.01f; _size = size; m_taintsize = _size; if (!QuaternionIsFinite(rotation)) { rotation = Quaternion.Identity; m_log.Warn("[PHYSICS]: Got nonFinite Object create Rotation"); } _orientation = rotation; m_taintrot = _orientation; _mesh = mesh; _pbs = pbs; _parent_scene = parent_scene; m_targetSpace = (IntPtr)0; if (pos.Z < 0) m_isphysical = false; else { m_isphysical = pisPhysical; // If we're physical, we need to be in the master space for now. // linksets *should* be in a space together.. but are not currently if (m_isphysical) m_targetSpace = _parent_scene.space; } m_primName = primName; m_taintadd = true; _parent_scene.AddPhysicsActorTaint(this); // don't do .add() here; old geoms get recycled with the same hash }
public AuroraODEPrim(string name, byte physicsType, PrimitiveBaseShape shape, Vector3 position, Vector3 size, Quaternion rotation, int material, float friction, float restitution, float gravityMultiplier, float density, AuroraODEPhysicsScene parent_scene) { m_vehicle = new AuroraODEDynamics(); // correct for changed timestep PID_D /= (parent_scene.ODE_STEPSIZE*50f); // original ode fps of 50 PID_G /= (parent_scene.ODE_STEPSIZE*50f); body_autodisable_frames = parent_scene.bodyFramesAutoDisable; prim_geom = IntPtr.Zero; _name = name; PhysicsShapeType = physicsType; _size = size; _position = position; fakepos = 0; _orientation = rotation; fakeori = 0; _pbs = shape; _parent_scene = parent_scene; m_targetSpace = IntPtr.Zero; /* m_isphysical = pisPhysical; if (m_isphysical) m_targetSpace = _parent_scene.space; */ m_isphysical = false; m_forceacc = Vector3.Zero; m_angularforceacc = Vector3.Zero; hasOOBoffsetFromMesh = false; _triMeshData = IntPtr.Zero; SetMaterial(material, friction, restitution, gravityMultiplier, density); CalcPrimBodyData(); _parent_scene.AddSimulationChange(() => changeadd()); }
public AuroraODEPrim (ISceneChildEntity entity, AuroraODEPhysicsScene parent_scene, bool pisPhysical) { m_vehicle = new AuroraODEDynamics (); //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); PID_D = parent_scene.bodyPIDD; PID_G = parent_scene.bodyPIDG; // correct for changed timestep PID_D /= (parent_scene.ODE_STEPSIZE * 50f); // original ode fps of 50 PID_G /= (parent_scene.ODE_STEPSIZE * 50f); body_autodisable_frames = parent_scene.bodyFramesAutoDisable; prim_geom = IntPtr.Zero; _size = entity.Scale; _position = entity.AbsolutePosition; fakepos = 0; _orientation = entity.GetWorldRotation (); fakeori = 0; _pbs = entity.Shape; _parent_entity = entity; _parent_scene = parent_scene; m_targetSpace = IntPtr.Zero; /* m_isphysical = pisPhysical; if (m_isphysical) m_targetSpace = _parent_scene.space; */ m_isphysical = false; m_forceacc = Vector3.Zero; m_angularforceacc = Vector3.Zero; hasOOBoffsetFromMesh = false; _triMeshData = IntPtr.Zero; CalcPrimBodyData(); m_UpdateTimecntr = 0; m_UpdateFPScntr = 2.5f * parent_scene.StepTime; // this parameter needs retunning and possible came from ini file if (m_UpdateTimecntr > .1f) // try to keep it under 100ms m_UpdateTimecntr = .1f; AddChange (changes.Add, null); }
public AuroraODEPrim (ISceneChildEntity entity, AuroraODEPhysicsScene parent_scene, bool pisPhysical, CollisionLocker dode) { m_vehicle = new AuroraODEDynamics (); //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); ode = dode; PID_D = parent_scene.bodyPIDD; PID_G = parent_scene.bodyPIDG; // correct for changed timestep PID_D /= (parent_scene.ODE_STEPSIZE * 50f); // original ode fps of 50 PID_G /= (parent_scene.ODE_STEPSIZE * 50f); // m_tensor = parent_scene.bodyMotorJointMaxforceTensor; body_autodisable_frames = parent_scene.bodyFramesAutoDisable; prim_geom = IntPtr.Zero; prev_geom = IntPtr.Zero; _size = entity.Scale; _position = entity.AbsolutePosition; fakepos = false; _orientation = entity.GetWorldRotation (); fakeori = false; _pbs = entity.Shape; _parent_entity = entity; _parent_scene = parent_scene; m_targetSpace = (IntPtr)0; m_isphysical = pisPhysical; // If we're physical, we need to be in the master space for now. // linksets *should* be in a space together.. but are not currently if (m_isphysical) m_targetSpace = _parent_scene.space; m_forceacc = Vector3.Zero; m_angularforceacc = Vector3.Zero; m_UpdateTimecntr = 0; m_UpdateFPScntr = 2.5f * parent_scene.StepTime; // this parameter needs retunning and possible came from ini file if (m_UpdateTimecntr > .1f) // try to keep it under 100ms m_UpdateTimecntr = .1f; AddChange (changes.Add, null); }
private Vector3 showposition; // a temp hack for now rest of code expects position to be changed immediately public AuroraODEPrim(ISceneChildEntity entity, AuroraODEPhysicsScene parent_scene, bool pisPhysical) { m_vehicle = new AuroraODEDynamics(); //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); // correct for changed timestep PID_D /= (parent_scene.ODE_STEPSIZE * 50f); // original ode fps of 50 PID_G /= (parent_scene.ODE_STEPSIZE * 50f); body_autodisable_frames = parent_scene.bodyFramesAutoDisable; prim_geom = IntPtr.Zero; _size = entity.Scale; _position = entity.AbsolutePosition; fakepos = 0; _orientation = entity.GetWorldRotation(); fakeori = 0; _pbs = entity.Shape; _parent_entity = entity; _parent_scene = parent_scene; m_targetSpace = IntPtr.Zero; /* m_isphysical = pisPhysical; if (m_isphysical) m_targetSpace = _parent_scene.space; */ m_isphysical = false; m_forceacc = Vector3.Zero; m_angularforceacc = Vector3.Zero; hasOOBoffsetFromMesh = false; _triMeshData = IntPtr.Zero; CalcPrimBodyData(); _parent_scene.AddSimulationChange(() => changeadd()); }