public AuroraODECharacter(String avName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Quaternion rotation, Vector3 size) { m_uuid = UUID.Random(); _parent_scene = parent_scene; m_taintRotation = rotation; if (pos.IsFinite()) { if (pos.Z > 9999999f || pos.Z < -90f) { pos.Z = _parent_scene.GetTerrainHeightAtXY(_parent_scene.Region.RegionSizeX * 0.5f, _parent_scene.Region.RegionSizeY * 0.5f) + 5.0f; } _position = pos; } else { _position.X = _parent_scene.Region.RegionSizeX * 0.5f; _position.Y = _parent_scene.Region.RegionSizeY * 0.5f; _position.Z = _parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + 10f; MainConsole.Instance.Warn("[PHYSICS]: Got NaN Position on Character Create"); } m_isPhysical = false; // current status: no ODE information exists Size = size; m_name = avName; }
public AuroraODERayCastRequestManager(AuroraODEPhysicsScene pScene) { m_scene = pScene; nearCallback = near; ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); }
/// <summary> /// Dereference the creator scene so that it can be garbage collected if needed. /// </summary> internal void Dispose() { m_scene = null; if (ContactgeomsArray != IntPtr.Zero) { Marshal.FreeHGlobal(ContactgeomsArray); } }
public PhysicsScene GetScene(String sceneIdentifier) { if (_mScene == null) { if (!m_initialized) //Only initialize ode once! { // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to // http://opensimulator.org/mantis/view.php?id=2750). d.InitODE(); m_initialized = true; } _mScene = new AuroraODEPhysicsScene(ode, sceneIdentifier); } return(_mScene); }
public ODESpecificAvatar(String avName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Quaternion rotation, Vector3 size) : base(avName, parent_scene, pos, rotation, size) { base._parent_ref = this; }
public void setMesh (AuroraODEPhysicsScene parent_scene, IMesh mesh) { // This sleeper is there to moderate how long it takes between // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object //Thread.Sleep(10); //Kill Body so that mesh can re-make the geom if (IsPhysical && Body != IntPtr.Zero) { if (childPrim) { if (_parent != null) { AuroraPhysXPrim parent = (AuroraPhysXPrim)_parent; parent.ChildDelink (this); } } else { DestroyBody (); } } IntPtr vertices, indices; int vertexCount, indexCount; int vertexStride, triStride; mesh.getVertexListAsPtrToFloatArray (out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap mesh.getIndexListAsPtrToIntArray (out indices, out triStride, out indexCount); // Also fixed, needs release after usage mesh.releaseSourceMeshData (); // free up the original mesh data to save memory if (m_MeshToTriMeshMap.ContainsKey (mesh)) { _triMeshData = m_MeshToTriMeshMap[mesh]; } else { _triMeshData = d.GeomTriMeshDataCreate (); d.GeomTriMeshDataBuildSimple (_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); d.GeomTriMeshDataPreprocess (_triMeshData); m_MeshToTriMeshMap[mesh] = _triMeshData; } _parent_scene.waitForSpaceUnlock (m_targetSpace); try { if (prim_geom == IntPtr.Zero) { SetGeom (d.CreateTriMesh (m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); } } catch (AccessViolationException) { m_log.Error ("[PHYSICS]: MESH LOCKED"); return; } }
public AuroraPhysXPrim(ISceneChildEntity entity, AuroraODEPhysicsScene parent_scene, bool pisPhysical, CollisionLocker dode) { m_vehicle = new AuroraPhysXDynamics (); //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); }
public AuroraODERayCastRequestManager(AuroraODEPhysicsScene pScene) { m_scene = pScene; nearCallback = near; }
/// <summary> /// Dereference the creator scene so that it can be garbage collected if needed. /// </summary> internal void Dispose() { m_scene = null; }
public AuroraPhysXCharacter (String avName, AuroraPhysXPhysicsScene parent_scene, Vector3 pos, Quaternion rotation, Vector3 size) { m_uuid = UUID.Random(); m_taintRotation = rotation; // _orientation = rotation; // _lastorientation = rotation; if (pos.IsFinite()) { if (pos.Z > 9999999f || pos.Z <-90f) { // pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; pos.Z = parent_scene.GetTerrainHeightAtXY(parent_scene.Region.RegionSizeX * 0.5f, parent_scene.Region.RegionSizeY * 0.5f) + 5.0f; } _position = pos; m_taintPosition.X = pos.X; m_taintPosition.Y = pos.Y; m_taintPosition.Z = pos.Z; } else { _position.X = (float)parent_scene.Region.RegionSizeX * 0.5f; _position.Y = (float)parent_scene.Region.RegionSizeY * 0.5f; _position.Z = parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + 10f; m_taintPosition.X = _position.X; m_taintPosition.Y = _position.Y; m_taintPosition.Z = _position.Z; m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); } _parent_scene = parent_scene; CAPSULE_RADIUS = parent_scene.avCapRadius; // m_StandUpRotation = // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, // 0.5f); CAPSULE_LENGTH = (size.Z * 1.1f) - CAPSULE_RADIUS * 2.0f; if ((m_collisionFlags & CollisionCategories.Land) == 0) AvatarHalfsize = CAPSULE_LENGTH * 0.5f + CAPSULE_RADIUS; else AvatarHalfsize = CAPSULE_LENGTH * 0.5f + CAPSULE_RADIUS - 0.3f; //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH; m_isPhysical = false; // current status: no ODE information exists m_tainted_isPhysical = true; // new tainted status: need to create ODE information _parent_scene.AddPhysicsActorTaint(this); 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; m_name = avName; }