// Create the correct type of linkset for this child public static BSLinkset Factory(BSScene physScene, BSPrimLinkable parent) { BSLinkset ret = null; switch (parent.LinksetType) { case LinksetImplementation.Constraint: ret = new BSLinksetConstraints(physScene, parent); break; case LinksetImplementation.Compound: ret = new BSLinksetCompound(physScene, parent); break; case LinksetImplementation.Manual: // ret = new BSLinksetManual(physScene, parent); break; default: ret = new BSLinksetCompound(physScene, parent); break; } if (ret == null) { physScene.Logger.ErrorFormat("[BULLETSIM LINKSET] Factory could not create linkset. Parent name={1}, ID={2}", parent.Name, parent.LocalID); } return(ret); }
// Dereferencing a compound shape releases the hold on all the child shapes. public override void Dereference(BSScene physicsScene) { lock (physShapeInfo) { this.DecrementReference(); physicsScene.DetailLog("{0},BSShapeCompound.Dereference,shape={1}", BSScene.DetailLogZero, this); if (referenceCount <= 0) { if (!physicsScene.PE.IsCompound(physShapeInfo)) { // Failed the sanity check!! physicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}", LogHeader, physShapeInfo.shapeType, physShapeInfo.AddrString); physicsScene.DetailLog("{0},BSShapeCollection.DereferenceCompound,notACompoundShape,type={1},ptr={2}", BSScene.DetailLogZero, physShapeInfo.shapeType, physShapeInfo.AddrString); return; } int numChildren = physicsScene.PE.GetNumberOfCompoundChildren(physShapeInfo); physicsScene.DetailLog("{0},BSShapeCollection.DereferenceCompound,shape={1},children={2}", BSScene.DetailLogZero, physShapeInfo, numChildren); // Loop through all the children dereferencing each. for (int ii = numChildren - 1; ii >= 0; ii--) { BulletShape childShape = physicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(physShapeInfo, ii); DereferenceAnonCollisionShape(physicsScene, childShape); } physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); } } }
public static BSShape GetReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) { float lod; System.UInt64 newHullKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod); BSShapeHull retHull = null; lock (Hulls) { if (Hulls.TryGetValue(newHullKey, out retHull)) { // The mesh has already been created. Return a new reference to same. retHull.IncrementReference(); } else { retHull = new BSShapeHull(new BulletShape()); // An instance of this mesh has not been created. Build and remember same. BulletShape newShape = retHull.CreatePhysicalHull(physicsScene, prim, newHullKey, prim.BaseShape, prim.Size, lod); // Check to see if hull was created (might require an asset). newShape = VerifyMeshCreated(physicsScene, newShape, prim); if (!newShape.isNativeShape || prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Failed) { // If a mesh was what was created, remember the built shape for later sharing. Hulls.Add(newHullKey, retHull); } retHull.physShapeInfo = newShape; } } physicsScene.DetailLog("{0},BSShapeHull,getReference,hull={1},size={2},lod={3}", prim.LocalID, retHull, prim.Size, lod); return(retHull); }
private static BulletShape CreatePhysicalNativeShape(BSScene physicsScene, BSPhysObject prim, BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) { BulletShape newShape; ShapeData nativeShapeData = new ShapeData(); nativeShapeData.Type = shapeType; nativeShapeData.ID = prim.LocalID; nativeShapeData.Scale = prim.Scale; nativeShapeData.Size = prim.Scale; nativeShapeData.MeshKey = (ulong)shapeKey; nativeShapeData.HullKey = (ulong)shapeKey; if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) { newShape = physicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale); physicsScene.DetailLog("{0},BSShapeNative,capsule,scale={1}", prim.LocalID, prim.Scale); } else { newShape = physicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData); } if (!newShape.HasPhysicalShape) { physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", LogHeader, prim.LocalID, shapeType); } newShape.shapeType = shapeType; newShape.isNativeShape = true; newShape.shapeKey = (UInt64)shapeKey; return(newShape); }
public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) { // Calling this reference means we want another handle to an existing shape // (usually linksets) so return this copy. IncrementReference(); return(this); }
private BSShapeNative(BSScene physicsScene, BSPhysObject prim, BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) { ShapeData nativeShapeData = new ShapeData(); nativeShapeData.Type = shapeType; nativeShapeData.ID = prim.LocalID; nativeShapeData.Scale = prim.Scale; nativeShapeData.Size = prim.Scale; nativeShapeData.MeshKey = (ulong)shapeKey; nativeShapeData.HullKey = (ulong)shapeKey; /* * if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) * { * ptr = PhysicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale); * physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); * } * else * { * ptr = PhysicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData); * } * if (ptr == IntPtr.Zero) * { * physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", * LogHeader, prim.LocalID, shapeType); * } * type = shapeType; * key = (UInt64)shapeKey; */ }
public BSActorLockAxis(BSScene physicsScene, BSPhysObject pObj, string actorName) : base(physicsScene, pObj, actorName) { m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID); LockAxisConstraint = null; HaveRegisteredForBeforeStepCallback = false; }
private BSShapeNative(BSScene physicsScene, BSPhysObject prim, BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) { ShapeData nativeShapeData = new ShapeData(); nativeShapeData.Type = shapeType; nativeShapeData.ID = prim.LocalID; nativeShapeData.Scale = prim.Scale; nativeShapeData.Size = prim.Scale; nativeShapeData.MeshKey = (ulong)shapeKey; nativeShapeData.HullKey = (ulong)shapeKey; if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) { ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); } else { ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData); } if (ptr == null) { physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", LogHeader, prim.LocalID, shapeType); } type = shapeType; key = (UInt64)shapeKey; }
public BSActorAvatarMove(BSScene physicsScene, BSPhysObject pObj, string actorName) : base(physicsScene, pObj, actorName) { m_velocityMotor = null; m_walkingUpStairs = 0; m_physicsScene.DetailLog("{0},BSActorAvatarMove,constructor", m_controllingPrim.LocalID); }
public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim, BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) { // Native shapes are not shared and are always built anew. //return new BSShapeNative(physicsScene, prim, shapeType, shapeKey); return(null); }
public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) { m_physicsScene = physicsScene; m_controllingPrim = pObj; ActorName = actorName; Enabled = true; }
// Make this reference to the physical shape go away since native shapes are not shared. public override void Dereference(BSScene physicsScene) { // Native shapes are not tracked and are released immediately physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr); ptr = null; // Garbage collection will free up this instance. }
public BSCharacter( uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying) : base(parent_scene, localID, avName, "BSCharacter") { _physicsActorType = (int)ActorTypes.Agent; RawPosition = pos; _flying = isFlying; RawOrientation = OMV.Quaternion.Identity; RawVelocity = vel; _buoyancy = ComputeBuoyancyFromFlying(isFlying); Friction = BSParam.AvatarStandingFriction; Density = BSParam.AvatarDensity; // Old versions of ScenePresence passed only the height. If width and/or depth are zero, // replace with the default values. _size = size; if (_size.X == 0f) { _size.X = BSParam.AvatarCapsuleDepth; } if (_size.Y == 0f) { _size.Y = BSParam.AvatarCapsuleWidth; } // The dimensions of the physical capsule are kept in the scale. // Physics creates a unit capsule which is scaled by the physics engine. Scale = ComputeAvatarScale(_size); // set _avatarVolume and _mass based on capsule size, _density and Scale ComputeAvatarVolumeAndMass(); DetailLog( "{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}", LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos, vel); // do actual creation in taint time PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate() { DetailLog("{0},BSCharacter.create,taint", LocalID); // New body and shape into PhysBody and PhysShape PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this); // The avatar's movement is controlled by this motor that speeds up and slows down // the avatar seeking to reach the motor's target speed. // This motor runs as a prestep action for the avatar so it will keep the avatar // standing as well as moving. Destruction of the avatar will destroy the pre-step action. m_moveActor = new BSActorAvatarMove(PhysScene, this, AvatarMoveActorName); PhysicalActors.Add(AvatarMoveActorName, m_moveActor); SetPhysicalProperties(); IsInitialized = true; }); return; }
public BSShapeCollection(BSScene physScene) { m_physicsScene = physScene; // Set the next to 'true' for very detailed shape update detailed logging (detailed details?) // While detailed debugging is still active, this is better than commenting out all the // DetailLog statements. When debugging slows down, this and the protected logging // statements can be commented/removed. DDetail = true; }
public void TearDown() { if (PhysicsScene != null) { // The Dispose() will also free any physical objects in the scene PhysicsScene.Dispose(); PhysicsScene = null; } }
// Apply the specificed collision mask into the physical world public virtual bool ApplyCollisionMask(BSScene physicsScene) { // Should assert the body has been added to the physical world. // (The collision masks are stored in the collision proxy cache which only exists for // a collision body that is in the world.) return(physicsScene.PE.SetCollisionGroupMask(this, BulletSimData.CollisionTypeMasks[collisionType].group, BulletSimData.CollisionTypeMasks[collisionType].mask)); }
// Dereferencing a compound shape releases the hold on all the child shapes. public override void Dereference(BSScene physicsScene) { lock (ConvexHulls) { this.DecrementReference(); physicsScene.DetailLog("{0},BSShapeConvexHull.Dereference,shape={1}", BSScene.DetailLogZero, this); // TODO: schedule aging and destruction of unused meshes. } }
// Make this reference to the physical shape go away since native shapes are not shared. public override void Dereference(BSScene physicsScene) { /* * // Native shapes are not tracked and are released immediately * physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); * PhysicsScene.PE.DeleteCollisionShape(physicsScene.World, this); * ptr = IntPtr.Zero; * // Garbage collection will free up this instance. */ }
public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) { // Default linkset implementation for this prim LinksetType = (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation; Linkset = BSLinkset.Factory(PhysScene, this); Linkset.Refresh(this); }
private BSShapeNative(BSScene physicsScene, BSPhysObject prim, BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) { ShapeData nativeShapeData = new ShapeData(); nativeShapeData.Type = shapeType; nativeShapeData.ID = prim.LocalID; nativeShapeData.Scale = prim.Scale; nativeShapeData.Size = prim.Scale; nativeShapeData.MeshKey = (ulong)shapeKey; nativeShapeData.HullKey = (ulong)shapeKey; }
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) { // Native shapes are not shared so we return a new shape. BSShape ret = null; lock (physShapeInfo) { ret = new BSShapeNative(CreatePhysicalNativeShape(pPhysicsScene, pPrim, physShapeInfo.shapeType, (FixedShapeKey)physShapeInfo.shapeKey)); } return(ret); }
public BSTerrainManager(BSScene physicsScene, Vector3 regionSize) { m_physicsScene = physicsScene; DefaultRegionSize = regionSize; m_terrains = new Dictionary <Vector3, BSTerrainPhys>(); // Assume one region of default size m_worldOffset = Vector3.Zero; m_worldMax = new Vector3(DefaultRegionSize); MegaRegionParentPhysicsScene = null; }
// 'engineName' is the Bullet engine to use. Either null (for unmanaged), "BulletUnmanaged" or "BulletXNA" // 'params' is a set of keyValue pairs to set in the engine's configuration file (override defaults) // May be 'null' if there are no overrides. public static BSScene CreateBasicPhysicsEngine(Dictionary <string, string> paramOverrides) { IConfigSource openSimINI = new IniConfigSource(); IConfig startupConfig = openSimINI.AddConfig("Startup"); startupConfig.Set("physics", "BulletSim"); startupConfig.Set("meshing", "Meshmerizer"); startupConfig.Set("cacheSculptMaps", "false"); // meshmerizer shouldn't save maps IConfig bulletSimConfig = openSimINI.AddConfig("BulletSim"); // If the caller cares, specify the bullet engine otherwise it will default to "BulletUnmanaged". // bulletSimConfig.Set("BulletEngine", "BulletUnmanaged"); // bulletSimConfig.Set("BulletEngine", "BulletXNA"); bulletSimConfig.Set("MeshSculptedPrim", "false"); bulletSimConfig.Set("ForceSimplePrimMeshing", "true"); if (paramOverrides != null) { foreach (KeyValuePair <string, string> kvp in paramOverrides) { bulletSimConfig.Set(kvp.Key, kvp.Value); } } // If a special directory exists, put detailed logging therein. // This allows local testing/debugging without having to worry that the build engine will output logs. if (Directory.Exists("physlogs")) { bulletSimConfig.Set("PhysicsLoggingDir", "./physlogs"); bulletSimConfig.Set("PhysicsLoggingEnabled", "True"); bulletSimConfig.Set("PhysicsLoggingDoFlush", "True"); bulletSimConfig.Set("VehicleLoggingEnabled", "True"); } PhysicsPluginManager physicsPluginManager; physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssemblies("Physics"); Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); PhysicsScene pScene = physicsPluginManager.GetPhysicsScene( "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent); BSScene bsScene = pScene as BSScene; // Since the asset requestor is not initialized, any mesh or sculptie will be a cube. // In the future, add a fake asset fetcher to get meshes and sculpts. // bsScene.RequestAssetMethod = ???; return(bsScene); }
// This minCoords and maxCoords passed in give the size of the terrain (min and max Z // are the high and low points of the heightmap). public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap, Vector3 minCoords, Vector3 maxCoords) : base(physicsScene, regionBase, id) { m_mapInfo = new BulletHMapInfo(id, initialMap, maxCoords.X - minCoords.X, maxCoords.Y - minCoords.Y); m_mapInfo.minCoords = minCoords; m_mapInfo.maxCoords = maxCoords; m_mapInfo.minZ = minCoords.Z; m_mapInfo.maxZ = maxCoords.Z; m_mapInfo.terrainRegionBase = TerrainBase; // Don't have to free any previous since we just got here. BuildHeightmapTerrain(); }
// Make this reference to the physical shape go away since native shapes are not shared. public override void Dereference(BSScene physicsScene) { // Native shapes are not tracked and are released immediately lock (physShapeInfo) { if (physShapeInfo.HasPhysicalShape) { physicsScene.DetailLog("{0},BSShapeNative.Dereference,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); } physShapeInfo.Clear(); // Garbage collection will free up this instance. } }
public static BSShape GetReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) { float lod; System.UInt64 newMeshKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod); physicsScene.DetailLog("{0},BSShapeMesh,getReference,newKey={1},size={2},lod={3}", prim.LocalID, newMeshKey.ToString("X"), prim.Size, lod); BSShapeConvexHull retConvexHull = null; lock (ConvexHulls) { if (ConvexHulls.TryGetValue(newMeshKey, out retConvexHull)) { // The mesh has already been created. Return a new reference to same. retConvexHull.IncrementReference(); } else { retConvexHull = new BSShapeConvexHull(new BulletShape()); BulletShape convexShape = null; // Get a handle to a mesh to build the hull from BSShape baseMesh = BSShapeMesh.GetReference(physicsScene, false /* forceRebuild */, prim); if (baseMesh.physShapeInfo.isNativeShape) { // We get here if the mesh was not creatable. Could be waiting for an asset from the disk. // In the short term, we return the native shape and a later ForceBodyShapeRebuild should // get back to this code with a buildable mesh. // TODO: not sure the temp native shape is freed when the mesh is rebuilt. When does this get freed? convexShape = baseMesh.physShapeInfo; } else { convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo); convexShape.shapeKey = newMeshKey; ConvexHulls.Add(convexShape.shapeKey, retConvexHull); } // Done with the base mesh baseMesh.Dereference(physicsScene); retConvexHull.physShapeInfo = convexShape; } } return(retConvexHull); }
protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName) { IsInitialized = false; PhysScene = parentScene; LocalID = localID; PhysObjectName = name; Name = name; // PhysicsActor also has the name of the object. Someday consolidate. TypeName = typeName; // Oddity if object is destroyed and recreated very quickly it could still have the old body. if (!PhysBody.HasPhysicalBody) { PhysBody = new BulletBody(localID); } // Clean out anything that might be in the physical actor list. // Again, a workaround for destroying and recreating an object very quickly. PhysicalActors.Dispose(); UserSetCenterOfMassDisplacement = null; PrimAssetState = PrimAssetCondition.Unknown; // Initialize variables kept in base. // Beware that these cause taints to be queued whch can cause race conditions on startup. GravModifier = 1.0f; Gravity = new OMV.Vector3(0f, 0f, BSParam.Gravity); HoverActive = false; // Default material type. Also sets Friction, Restitution and Density. SetMaterial((int)MaterialAttributes.Material.Wood); CollisionsLastTickStep = -1; SubscribedEventsMs = 0; // Crazy values that will never be true CollidingStep = BSScene.NotASimulationStep; CollidingGroundStep = BSScene.NotASimulationStep; CollisionAccumulation = BSScene.NotASimulationStep; ColliderIsMoving = false; CollisionScore = 0; // All axis free. LockedLinearAxis = LockedAxisFree; LockedAngularAxis = LockedAxisFree; }
public BSCharacter( uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, float footOffset, bool isFlying) : base(parent_scene, localID, avName, "BSCharacter") { _physicsActorType = (int)ActorTypes.Agent; RawPosition = pos; _flying = isFlying; RawOrientation = OMV.Quaternion.Identity; RawVelocity = vel; _buoyancy = ComputeBuoyancyFromFlying(isFlying); Friction = BSParam.AvatarStandingFriction; Density = BSParam.AvatarDensity; _isPhysical = true; _footOffset = footOffset; // Adjustments for zero X and Y made in Size() // This also computes avatar scale, volume, and mass SetAvatarSize(size, footOffset, true /* initializing */); DetailLog( "{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5},pos={6},vel={7}", LocalID, Size, Scale, Density, _avatarVolume, RawMass, pos, vel); // do actual creation in taint time PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate() { DetailLog("{0},BSCharacter.create,taint", LocalID); // New body and shape into PhysBody and PhysShape PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this); // The avatar's movement is controlled by this motor that speeds up and slows down // the avatar seeking to reach the motor's target speed. // This motor runs as a prestep action for the avatar so it will keep the avatar // standing as well as moving. Destruction of the avatar will destroy the pre-step action. m_moveActor = new BSActorAvatarMove(PhysScene, this, AvatarMoveActorName); PhysicalActors.Add(AvatarMoveActorName, m_moveActor); SetPhysicalProperties(); IsInitialized = true; }); return; }
protected BSLinkset(BSScene scene, BSPrimLinkable parent) { // A simple linkset of one (no children) LinksetID = m_nextLinksetID++; // We create LOTS of linksets. if (m_nextLinksetID <= 0) { m_nextLinksetID = 1; } m_physicsScene = scene; LinksetRoot = parent; m_children = new Dictionary <BSPrimLinkable, BSLinkInfo>(); LinksetMass = parent.RawMass; Rebuilding = false; RebuildScheduled = false; parent.ClearDisplacement(); }
// Constructor to build a default, flat heightmap terrain. public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) : base(physicsScene, regionBase, id) { Vector3 minTerrainCoords = new Vector3(0f, 0f, BSTerrainManager.HEIGHT_INITIALIZATION - BSTerrainManager.HEIGHT_EQUAL_FUDGE); Vector3 maxTerrainCoords = new Vector3(regionSize.X, regionSize.Y, BSTerrainManager.HEIGHT_INITIALIZATION); int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y; float[] initialMap = new float[totalHeights]; for (int ii = 0; ii < totalHeights; ii++) { initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; } m_mapInfo = new BulletHMapInfo(id, initialMap, regionSize.X, regionSize.Y); m_mapInfo.minCoords = minTerrainCoords; m_mapInfo.maxCoords = maxTerrainCoords; m_mapInfo.terrainRegionBase = TerrainBase; // Don't have to free any previous since we just got here. BuildHeightmapTerrain(); }
// 'engineName' is the Bullet engine to use. Either null (for unmanaged), "BulletUnmanaged" or "BulletXNA" // 'params' is a set of keyValue pairs to set in the engine's configuration file (override defaults) // May be 'null' if there are no overrides. public static BSScene CreateBasicPhysicsEngine(Dictionary<string,string> paramOverrides) { IConfigSource openSimINI = new IniConfigSource(); IConfig startupConfig = openSimINI.AddConfig("Startup"); startupConfig.Set("physics", "BulletSim"); startupConfig.Set("meshing", "Meshmerizer"); startupConfig.Set("cacheSculptMaps", "false"); // meshmerizer shouldn't save maps IConfig bulletSimConfig = openSimINI.AddConfig("BulletSim"); // If the caller cares, specify the bullet engine otherwise it will default to "BulletUnmanaged". // bulletSimConfig.Set("BulletEngine", "BulletUnmanaged"); // bulletSimConfig.Set("BulletEngine", "BulletXNA"); bulletSimConfig.Set("MeshSculptedPrim", "false"); bulletSimConfig.Set("ForceSimplePrimMeshing", "true"); if (paramOverrides != null) { foreach (KeyValuePair<string, string> kvp in paramOverrides) { bulletSimConfig.Set(kvp.Key, kvp.Value); } } // If a special directory exists, put detailed logging therein. // This allows local testing/debugging without having to worry that the build engine will output logs. if (Directory.Exists("physlogs")) { bulletSimConfig.Set("PhysicsLoggingDir","./physlogs"); bulletSimConfig.Set("PhysicsLoggingEnabled","True"); bulletSimConfig.Set("PhysicsLoggingDoFlush","True"); bulletSimConfig.Set("VehicleLoggingEnabled","True"); } Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); RegionInfo info = new RegionInfo(); info.RegionName = "BSTestRegion"; info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info); IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer(); INonSharedRegionModule mod = mesher as INonSharedRegionModule; mod.Initialise(openSimINI); mod.AddRegion(scene); mod.RegionLoaded(scene); BSScene pScene = new BSScene(); mod = (pScene as INonSharedRegionModule); mod.Initialise(openSimINI); mod.AddRegion(scene); mod.RegionLoaded(scene); // Since the asset requestor is not initialized, any mesh or sculptie will be a cube. // In the future, add a fake asset fetcher to get meshes and sculpts. // bsScene.RequestAssetMethod = ???; return pScene; }