// Select the connection to the actual Bullet implementation. // The main engine selection is the engineName up to the first hypen. // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name // is passed to the engine to do its special selection, etc. private BSAPITemplate SelectUnderlyingBulletEngine(string engineName) { // For the moment, do a simple switch statement. // Someday do fancyness with looking up the interfaces in the assembly. BSAPITemplate ret = null; string selectionName = engineName.ToLower(); int hyphenIndex = engineName.IndexOf("-"); if (hyphenIndex > 0) selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1); switch (selectionName) { case "bullet": case "bulletunmanaged": ret = new BSAPIUnman(engineName, this); break; case "bulletxna": ret = new BSAPIXNA(engineName, this); // Disable some features that are not implemented in BulletXNA m_log.InfoFormat("{0} Disabling some physics features not implemented by BulletXNA", LogHeader); m_log.InfoFormat("{0} Disabling ShouldUseBulletHACD", LogHeader); BSParam.ShouldUseBulletHACD = false; m_log.InfoFormat("{0} Disabling ShouldUseSingleConvexHullForPrims", LogHeader); BSParam.ShouldUseSingleConvexHullForPrims = false; m_log.InfoFormat("{0} Disabling ShouldUseGImpactShapeForPrims", LogHeader); BSParam.ShouldUseGImpactShapeForPrims = false; m_log.InfoFormat("{0} Setting terrain implimentation to Heightmap", LogHeader); BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap; break; } if (ret == null) { m_log.ErrorFormat("{0) COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader); } else { m_log.InfoFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion); } return ret; }
private static void RecordCollision(BSAPIXNA world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm, float penetration) { IndexedVector3 contactNormal = norm; if ((objA.GetCollisionFlags() & BulletXNA.BulletCollision.CollisionFlags.BS_WANTS_COLLISIONS) == 0 && (objB.GetCollisionFlags() & BulletXNA.BulletCollision.CollisionFlags.BS_WANTS_COLLISIONS) == 0) { return; } uint idA = (uint)objA.GetUserPointer(); uint idB = (uint)objB.GetUserPointer(); if (idA > idB) { uint temp = idA; idA = idB; idB = temp; contactNormal = -contactNormal; } //ulong collisionID = ((ulong) idA << 32) | idB; CollisionDesc cDesc = new CollisionDesc() { aID = idA, bID = idB, point = new Vector3(contact.X,contact.Y,contact.Z), normal = new Vector3(contactNormal.X,contactNormal.Y,contactNormal.Z), penetration = penetration }; if (world.LastCollisionDesc < world.UpdatedCollisions.Length) world.UpdatedCollisions[world.LastCollisionDesc++] = (cDesc); m_collisionsThisFrame++; }
public SimMotionState(BSAPIXNA pWorld, uint id, IndexedMatrix starTransform, object frameUpdates) { IndexedQuaternion OrientationQuaterion = starTransform.GetRotation(); m_properties = new EntityProperties() { ID = id, Position = new Vector3(starTransform._origin.X, starTransform._origin.Y,starTransform._origin.Z), Rotation = new Quaternion(OrientationQuaterion.X,OrientationQuaterion.Y,OrientationQuaterion.Z,OrientationQuaterion.W) }; m_lastProperties = new EntityProperties() { ID = id, Position = new Vector3(starTransform._origin.X, starTransform._origin.Y, starTransform._origin.Z), Rotation = new Quaternion(OrientationQuaterion.X, OrientationQuaterion.Y, OrientationQuaterion.Z, OrientationQuaterion.W) }; m_world = pWorld; m_xform = starTransform; }
// Select the connection to the actual Bullet implementation. // The main engine selection is the engineName up to the first hypen. // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name // is passed to the engine to do its special selection, etc. private BSAPITemplate SelectUnderlyingBulletEngine(string engineName) { // For the moment, do a simple switch statement. // Someday do fancyness with looking up the interfaces in the assembly. BSAPITemplate ret = null; string selectionName = engineName.ToLower(); int hyphenIndex = engineName.IndexOf("-"); if (hyphenIndex > 0) selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1); switch (selectionName) { case "bulletunmanaged": ret = new BSAPIUnman(engineName, this); break; case "bulletxna": ret = new BSAPIXNA(engineName, this); break; } if (ret == null) { m_log.ErrorFormat("{0) COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader); } else { m_log.WarnFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion); } return ret; }