Пример #1
0
 public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName)
 {
     m_physicsScene = physicsScene;
     m_controllingPrim = pObj;
     ActorName = actorName;
     Enabled = true;
 }
Пример #2
0
 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);
 }
Пример #3
0
    public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                       OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
            : base(parent_scene, localID, primName, "BSPrim")
    {
        // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
        _physicsActorType = (int)ActorTypes.Prim;
        _position = pos;
        _size = size;
        Scale = size;   // prims are the size the user wants them to be (different for BSCharactes).
        _orientation = rotation;
        _buoyancy = 0f;
        RawVelocity = OMV.Vector3.Zero;
        _rotationalVelocity = OMV.Vector3.Zero;
        BaseShape = pbs;
        _isPhysical = pisPhysical;
        _isVolumeDetect = false;

        // We keep a handle to the vehicle actor so we can set vehicle parameters later.
        VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName);
        PhysicalActors.Add(VehicleActorName, VehicleActor);

        _mass = CalculateMass();

        // DetailLog("{0},BSPrim.constructor,call", LocalID);
        // do the actual object creation at taint time
        PhysScene.TaintedObject("BSPrim.create", delegate()
        {
            // Make sure the object is being created with some sanity.
            ExtremeSanityCheck(true /* inTaintTime */);

            CreateGeomAndObject(true);

            CurrentCollisionFlags = PhysScene.PE.GetCollisionFlags(PhysBody);
        });
    }
Пример #4
0
        // 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);
        }
Пример #5
0
    // Get a reference to a physical shape. Create if it doesn't exist
    public static BSShape GetShapeReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
    {
        BSShape ret = null;

        if (prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE)
        {
            // an avatar capsule is close to a native shape (it is not shared)
            ret = BSShapeNative.GetReference(physicsScene, prim, BSPhysicsShapeType.SHAPE_CAPSULE,
                                        FixedShapeKey.KEY_CAPSULE);
            physicsScene.DetailLog("{0},BSShape.GetShapeReference,avatarCapsule,shape={1}", prim.LocalID, ret);
        }

        // Compound shapes are handled special as they are rebuilt from scratch.
        // This isn't too great a hardship since most of the child shapes will already been created.
        if (ret == null  && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND)
        {
            // Getting a reference to a compound shape gets you the compound shape with the root prim shape added
            ret = BSShapeCompound.GetReference(prim);
            physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret);
        }

        if (ret == null)
            ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim);

        return ret;
    }
Пример #6
0
 public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName)
 {
     m_physicsScene    = physicsScene;
     m_controllingPrim = pObj;
     ActorName         = actorName;
     Enabled           = true;
 }
Пример #7
0
        // Get a reference to a physical shape. Create if it doesn't exist
        public static BSShape GetShapeReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
        {
            BSShape ret = null;

            if (prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE)
            {
            // an avatar capsule is close to a native shape (it is not shared)
            ret = BSShapeNative.GetReference(physicsScene, prim, BSPhysicsShapeType.SHAPE_CAPSULE,
                                        FixedShapeKey.KEY_CAPSULE);
            physicsScene.DetailLog("{0},BSShape.GetShapeReference,avatarCapsule,shape={1}", prim.LocalID, ret);
            }

            // Compound shapes are handled special as they are rebuilt from scratch.
            // This isn't too great a hardship since most of the child shapes will have already been created.
            if (ret == null  && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND)
            {
            // Getting a reference to a compound shape gets you the compound shape with the root prim shape added
            ret = BSShapeCompound.GetReference(prim);
            physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret);
            }

            // Avatars have their own unique shape
            if (ret == null  && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_AVATAR)
            {
            // Getting a reference to a compound shape gets you the compound shape with the root prim shape added
            ret = BSShapeAvatar.GetReference(prim);
            physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,avatarShape,shape={1}", prim.LocalID, ret);
            }

            if (ret == null)
            ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim);

            return ret;
        }
Пример #8
0
    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;
         */
    }
Пример #9
0
    protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
    {
        PhysicsScene = parentScene;
        LocalID = localID;
        PhysObjectName = name;
        Name = name;    // PhysicsActor also has the name of the object. Someday consolidate.
        TypeName = typeName;

        // Initialize variables kept in base.
        GravModifier = 1.0f;
        Gravity = new OMV.Vector3(0f, 0f, BSParam.Gravity);

        // We don't have any physical representation yet.
        PhysBody = new BulletBody(localID);
        PhysShape = new BulletShape();

        LastAssetBuildFailed = false;

        // Default material type. Also sets Friction, Restitution and Density.
        SetMaterial((int)MaterialAttributes.Material.Wood);

        CollisionCollection = new CollisionEventUpdate();
        CollisionsLastTick = CollisionCollection;
        SubscribedEventsMs = 0;
        CollidingStep = 0;
        CollidingGroundStep = 0;
        CollisionAccumulation = 0;
        ColliderIsMoving = false;
        CollisionScore = 0;

        // All axis free.
        LockedAxis = LockedAxisFree;
    }
Пример #10
0
    // 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;
    }
Пример #11
0
 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;
 }
 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);
 }
Пример #13
0
 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;
 }
Пример #14
0
 public PhysicsScene GetScene()
 {
     if (_mScene == null)
     {
         _mScene = new BSScene();
     }
     return(_mScene);
 }
Пример #15
0
 public PhysicsScene GetScene(String sceneIdentifier)
 {
     if (_mScene == null)
     {
         _mScene = new BSScene(GetName(), sceneIdentifier);
     }
     return(_mScene);
 }
Пример #16
0
 public PhysicsScene GetScene(String sceneIdentifier)
 {
     if (_mScene == null)
     {
         _mScene = new BSScene(GetName(), sceneIdentifier);
     }
     return (_mScene);
 }
Пример #17
0
        public BSTerrainManager(BSScene physicsScene)
        {
            PhysicsScene = physicsScene;

            // Assume one region of default size
            m_worldMax = new Vector3(physicsScene.Scene.RegionInfo.RegionSizeX,
                                     physicsScene.Scene.RegionInfo.RegionSizeY, physicsScene.Scene.RegionInfo.RegionSizeZ);
        }
Пример #18
0
        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;
        }
Пример #19
0
    public BSActorLockAxis(BSScene physicsScene, BSPhysObject pObj, string actorName)
        : base(physicsScene, pObj, actorName)
    {
        m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID);
        LockAxisConstraint = null;

        // we place our constraint just before the simulation step to make sure the linkset is complete
        m_physicsScene.BeforeStep += PhysicsScene_BeforeStep;
    }
 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;
 }
Пример #21
0
        public BSActorLockAxis(BSScene physicsScene, BSPhysObject pObj, string actorName)
            : base(physicsScene, pObj, actorName)
        {
            m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID);
            LockAxisConstraint = null;

            // we place our constraint just before the simulation step to make sure the linkset is complete
            m_physicsScene.BeforeStep += PhysicsScene_BeforeStep;
        }
Пример #22
0
 public void TearDown()
 {
     if (PhysicsScene != null)
     {
         // The Dispose() will also free any physical objects in the scene
         PhysicsScene.Dispose();
         PhysicsScene = null;
     }
 }
Пример #23
0
 public BSShapeCollection(BSScene physScene)
 {
     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;
 }
Пример #24
0
 // 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));
 }
Пример #25
0
 // 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);
 }
Пример #26
0
 // 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.
      */
 }
Пример #27
0
        public BSTerrainManager(BSScene physicsScene)
        {
            m_physicsScene = physicsScene;
            m_terrains     = new Dictionary <Vector3, BSTerrainPhys>();

            // Assume one region of default size
            m_worldOffset = Vector3.Zero;
            m_worldMax    = new Vector3(DefaultRegionSize);
            MegaRegionParentPhysicsScene = null;
        }
Пример #28
0
        public BSTerrainManager(BSScene physicsScene)
        {
            PhysicsScene      = physicsScene;
            m_heightMaps      = new Dictionary <Vector2, BulletHeightMapInfo>();
            m_terrainModified = false;

            // Assume one region of default size
            m_worldOffset = Vector3.Zero;
            m_worldMax    = new Vector3(DefaultRegionSize);
            MegaRegionParentPhysicsScene = null;
        }
Пример #29
0
        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);
        }
Пример #30
0
        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)
        {
            Linkset = BSLinkset.Factory(PhysScene, this);

            PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
            {
                Linkset.Refresh(this);
            });
        }
Пример #31
0
    public PhysicsScene GetScene(String sceneIdentifier)
    {
        if (_mScene == null)
        {
            if (Util.IsWindows())
                Util.LoadArchSpecificWindowsDll("BulletSim.dll");

            _mScene = new BSScene(sceneIdentifier);
        }
        return (_mScene);
    }
Пример #32
0
    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);
    }
Пример #33
0
    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)
    {
        Linkset = BSLinkset.Factory(PhysScene, this);

        PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
        {
            Linkset.Refresh(this);
        });
    }
Пример #34
0
        public BSAPIUnman(string paramName, BSScene physScene)
        {
            PhysicsScene = physScene;

            // Do something fancy with the paramName to get the right DLL implementation
            //     like "Bullet-2.80-OpenCL-Intel" loading the version for Intel based OpenCL implementation, etc.
            if (Util.IsWindows())
            Util.LoadArchSpecificWindowsDll("BulletSim.dll");
            // If not Windows, loading is performed by the
            // Mono loader as specified in
            // "bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config".
        }
Пример #35
0
    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;
    }
Пример #36
0
        public PhysicsScene GetScene(String sceneIdentifier)
        {
            if (_mScene == null)
            {
                if (Util.IsWindows())
                {
                    Util.LoadArchSpecificWindowsDll("BulletSim.dll");
                }

                _mScene = new BSScene(sceneIdentifier);
            }
            return(_mScene);
        }
Пример #37
0
 public BSLinkset(BSScene scene, BSPhysObject parent)
 {
     // A simple linkset of one (no children)
     LinksetID = m_nextLinksetID++;
     // We create LOTS of linksets.
     if (m_nextLinksetID <= 0)
         m_nextLinksetID = 1;
     PhysicsScene = scene;
     LinksetRoot = parent;
     m_children = new List<BSPhysObject>();
     m_taintChildren = new List<BSPhysObject>();
     m_mass = parent.MassRaw;
 }
Пример #38
0
        protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName)
        {
            PhysicsScene   = parentScene;
            LocalID        = localID;
            PhysObjectName = name;
            TypeName       = typeName;

            Linkset = new BSLinkset(PhysicsScene, this);

            CollisionCollection = new CollisionEventUpdate();
            SubscribedEventsMs  = 0;
            CollidingStep       = 0;
            CollidingGroundStep = 0;
        }
Пример #39
0
    protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName)
    {
        PhysicsScene = parentScene;
        LocalID = localID;
        PhysObjectName = name;
        TypeName = typeName;

        Linkset = new BSLinkset(PhysicsScene, this);

        CollisionCollection = new CollisionEventUpdate();
        SubscribedEventsMs = 0;
        CollidingStep = 0;
        CollidingGroundStep = 0;
    }
Пример #40
0
    public PhysicsScene GetScene(String sceneIdentifier)
    {
        if (_mScene == null)
        {
            if (Util.IsWindows())
                Util.LoadArchSpecificWindowsDll("BulletSim.dll");
            // If not Windows, loading is performed by the
            // Mono loader as specified in
            // "bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config".

            _mScene = new BSScene(sceneIdentifier);
        }
        return (_mScene);
    }
Пример #41
0
        // 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);
            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();
        }
Пример #42
0
        // 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);
            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();
        }
Пример #43
0
        public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying)
        {
            base.BaseInitialize(parent_scene, localID, avName, "BSCharacter");
            _physicsActorType = (int)ActorTypes.Agent;
            _position         = pos;
            _size             = size;
            _flying           = isFlying;
            _orientation      = OMV.Quaternion.Identity;
            _velocity         = OMV.Vector3.Zero;
            _buoyancy         = ComputeBuoyancyFromFlying(isFlying);

            // The dimensions of the avatar capsule are kept in the scale.
            // Physics creates a unit capsule which is scaled by the physics engine.
            ComputeAvatarScale(_size);
            _avatarDensity = PhysicsScene.Params.avatarDensity;
            // set _avatarVolume and _mass based on capsule size, _density and _scale
            ComputeAvatarVolumeAndMass();

            ShapeData shapeData = new ShapeData();

            shapeData.ID          = LocalID;
            shapeData.Type        = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
            shapeData.Position    = _position;
            shapeData.Rotation    = _orientation;
            shapeData.Velocity    = _velocity;
            shapeData.Scale       = _scale;
            shapeData.Mass        = _mass;
            shapeData.Buoyancy    = _buoyancy;
            shapeData.Static      = ShapeData.numericFalse;
            shapeData.Friction    = PhysicsScene.Params.avatarFriction;
            shapeData.Restitution = PhysicsScene.Params.avatarRestitution;

            // do actual create at taint time
            PhysicsScene.TaintedObject("BSCharacter.create", delegate()
            {
                DetailLog("{0},BSCharacter.create,taint", LocalID);
                BulletSimAPI.CreateObject(PhysicsScene.WorldID, shapeData);

                // Set the buoyancy for flying. This will be refactored when all the settings happen in C#.
                // If not set at creation, the avatar will stop flying when created after crossing a region boundry.
                BulletSimAPI.SetObjectBuoyancy(PhysicsScene.WorldID, LocalID, _buoyancy);

                BSBody = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(PhysicsScene.World.ptr, LocalID));

                // This works here because CreateObject has already put the character into the physical world.
                BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr,
                                                     (uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask);
            });
            return;
        }
Пример #44
0
    public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying)
    {
        base.BaseInitialize(parent_scene, localID, avName, "BSCharacter");
        _physicsActorType = (int)ActorTypes.Agent;
        _position = pos;
        _size = size;
        _flying = isFlying;
        _orientation = OMV.Quaternion.Identity;
        _velocity = OMV.Vector3.Zero;
        _buoyancy = ComputeBuoyancyFromFlying(isFlying);

        // The dimensions of the avatar capsule are kept in the scale.
        // Physics creates a unit capsule which is scaled by the physics engine.
        ComputeAvatarScale(_size);
        _avatarDensity = PhysicsScene.Params.avatarDensity;
        // set _avatarVolume and _mass based on capsule size, _density and _scale
        ComputeAvatarVolumeAndMass();

        ShapeData shapeData = new ShapeData();
        shapeData.ID = LocalID;
        shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
        shapeData.Position = _position;
        shapeData.Rotation = _orientation;
        shapeData.Velocity = _velocity;
        shapeData.Scale = _scale;
        shapeData.Mass = _mass;
        shapeData.Buoyancy = _buoyancy;
        shapeData.Static = ShapeData.numericFalse;
        shapeData.Friction = PhysicsScene.Params.avatarFriction;
        shapeData.Restitution = PhysicsScene.Params.avatarRestitution;

        // do actual create at taint time
        PhysicsScene.TaintedObject("BSCharacter.create", delegate()
        {
            DetailLog("{0},BSCharacter.create,taint", LocalID);
            BulletSimAPI.CreateObject(PhysicsScene.WorldID, shapeData);

            // Set the buoyancy for flying. This will be refactored when all the settings happen in C#.
            // If not set at creation, the avatar will stop flying when created after crossing a region boundry.
            BulletSimAPI.SetObjectBuoyancy(PhysicsScene.WorldID, LocalID, _buoyancy);

            BSBody = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(PhysicsScene.World.ptr, LocalID));

            // This works here because CreateObject has already put the character into the physical world.
            BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr,
                            (uint)CollisionFilterGroups.AvatarFilter, (uint)CollisionFilterGroups.AvatarMask);
        });
        return;
    }
Пример #45
0
 public BSLinkset(BSScene scene, BSPhysObject parent)
 {
     // A simple linkset of one (no children)
     LinksetID = m_nextLinksetID++;
     // We create LOTS of linksets.
     if (m_nextLinksetID <= 0)
     {
         m_nextLinksetID = 1;
     }
     PhysicsScene    = scene;
     LinksetRoot     = parent;
     m_children      = new List <BSPhysObject>();
     m_taintChildren = new List <BSPhysObject>();
     m_mass          = parent.MassRaw;
 }
Пример #46
0
 protected BSLinkset(BSScene scene, BSPhysObject parent)
 {
     // A simple linkset of one (no children)
     LinksetID = m_nextLinksetID++;
     // We create LOTS of linksets.
     if (m_nextLinksetID <= 0)
     {
         m_nextLinksetID = 1;
     }
     PhysicsScene = scene;
     LinksetRoot  = parent;
     m_children   = new HashSet <BSPhysObject>();
     LinksetMass  = parent.RawMass;
     Rebuilding   = false;
 }
Пример #47
0
    // private static string LogHeader = "[BULLETSIM LINKSET]";

    // Create the correct type of linkset for this child
    public static BSLinkset Factory(BSScene physScene, BSPhysObject parent)
    {
        BSLinkset ret = null;
        /*
        if (parent.IsPhysical)
            ret = new BSLinksetConstraints(physScene, parent);
        else
            ret = new BSLinksetManual(physScene, parent);
         */

        // at the moment, there is only one
        ret = new BSLinksetConstraints(physScene, parent);

        return ret;
    }
Пример #48
0
        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;
            PhysicsScene = scene;
            LinksetRoot = parent;
            m_children = new HashSet<BSPrimLinkable>();
            LinksetMass = parent.RawMass;
            Rebuilding = false;

            parent.ClearDisplacement();
        }
Пример #49
0
        public BSCharacter(uint localID, UUID avID, String avName, BSScene parent_scene, Vector3 pos,
                           Quaternion rotation, Vector3 size, bool isFlying)
        {
            _localID     = localID;
            _avID        = avID;
            _avName      = avName;
            _scene       = parent_scene;
            _position    = pos;
            _orientation = rotation;
            _size        = size;
            _orientation = Quaternion.Identity;
            _velocity    = Vector3.Zero;
            _buoyancy    = 0f; // characters return a buoyancy of zero
            _scale       = new Vector3(1f, 1f, 1f);
            float AVvolume =
                (float)(Math.PI * Math.Pow(_scene.Params.avatarCapsuleRadius, 2) * _scene.Params.avatarCapsuleHeight);

            _density    = _scene.Params.avatarDensity;
            _mass       = _density * AVvolume;
            _isPhysical = true;

            ShapeData shapeData = new ShapeData
            {
                ID          = _localID,
                Type        = ShapeData.PhysicsShapeType.SHAPE_AVATAR,
                Position    = _position,
                Rotation    = _orientation,
                Velocity    = _velocity,
                Scale       = _scale,
                Mass        = _mass,
                Buoyancy    = isFlying ? 1f : 0f,
                Static      = ShapeData.numericFalse,
                Friction    = _scene.Params.avatarFriction,
                Restitution = _scene.Params.defaultRestitution
            };

            // do actual create at taint time
#if (!ISWIN)
            _scene.TaintedObject(delegate()
            {
                BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
            });
#else
            _scene.TaintedObject(() => BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData));
#endif

            return;
        }
Пример #50
0
        public PhysicsScene GetScene(String sceneIdentifier)
        {
            if (_mScene == null)
            {
                if (Util.IsWindows())
                {
                    Util.LoadArchSpecificWindowsDll("BulletSim.dll");
                }
                // If not Windows, loading is performed by the
                // Mono loader as specified in
                // "bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config".

                _mScene = new BSScene(sceneIdentifier);
            }
            return(_mScene);
        }
Пример #51
0
    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;

        // The collection of things that push me around
        PhysicalActors = new BSActorCollection(PhysScene);

        // We don't have any physical representation yet.
        PhysBody = new BulletBody(localID);
        PhysShape = new BSShapeNull();

        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);

        CollisionCollection = new CollisionEventUpdate();
        CollisionsLastReported = CollisionCollection;
        CollisionsLastTick = new CollisionEventUpdate();
        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;
    }
Пример #52
0
        public BSCharacter(uint localID, UUID avID, String avName, BSScene parent_scene, Vector3 pos,
                           Quaternion rotation, Vector3 size, bool isFlying)
        {
            _localID = localID;
            _avID = avID;
            _avName = avName;
            _scene = parent_scene;
            _position = pos;
            _orientation = rotation;
            _size = size;
            _orientation = Quaternion.Identity;
            _velocity = Vector3.Zero;
            _buoyancy = 0f; // characters return a buoyancy of zero
            _scale = new Vector3(1f, 1f, 1f);
            float AVvolume =
                (float) (Math.PI*Math.Pow(_scene.Params.avatarCapsuleRadius, 2)*_scene.Params.avatarCapsuleHeight);
            _density = _scene.Params.avatarDensity;
            _mass = _density*AVvolume;
            _isPhysical = true;

            ShapeData shapeData = new ShapeData
                                      {
                                          ID = _localID,
                                          Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR,
                                          Position = _position,
                                          Rotation = _orientation,
                                          Velocity = _velocity,
                                          Scale = _scale,
                                          Mass = _mass,
                                          Buoyancy = isFlying ? 1f : 0f,
                                          Static = ShapeData.numericFalse,
                                          Friction = _scene.Params.avatarFriction,
                                          Restitution = _scene.Params.defaultRestitution
                                      };

            // do actual create at taint time
#if (!ISWIN)
            _scene.TaintedObject(delegate()
            {
                BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
            });
#else
            _scene.TaintedObject(() => BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData));
#endif

            return;
        }
Пример #53
0
    public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying)
    {
        base.BaseInitialize(parent_scene, localID, avName, "BSCharacter");
        _physicsActorType = (int)ActorTypes.Agent;
        _position = pos;
        _size = size;
        _flying = isFlying;
        _orientation = OMV.Quaternion.Identity;
        _velocity = OMV.Vector3.Zero;
        _appliedVelocity = OMV.Vector3.Zero;
        _buoyancy = ComputeBuoyancyFromFlying(isFlying);
        _currentFriction = PhysicsScene.Params.avatarStandingFriction;
        _avatarDensity = PhysicsScene.Params.avatarDensity;

        // The dimensions of the avatar capsule are kept in the scale.
        // Physics creates a unit capsule which is scaled by the physics engine.
        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}",
                            LocalID, _size, Scale, _avatarDensity, _avatarVolume, MassRaw);

        ShapeData shapeData = new ShapeData();
        shapeData.ID = LocalID;
        shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
        shapeData.Position = _position;
        shapeData.Rotation = _orientation;
        shapeData.Velocity = _velocity;
        shapeData.Size = Scale; // capsule is a native shape but scale is not just <1,1,1>
        shapeData.Scale = Scale;
        shapeData.Mass = _mass;
        shapeData.Buoyancy = _buoyancy;
        shapeData.Static = ShapeData.numericFalse;
        shapeData.Friction = PhysicsScene.Params.avatarStandingFriction;
        shapeData.Restitution = PhysicsScene.Params.avatarRestitution;

        // do actual create at taint time
        PhysicsScene.TaintedObject("BSCharacter.create", delegate()
        {
            DetailLog("{0},BSCharacter.create,taint", LocalID);
            // New body and shape into BSBody and BSShape
            PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, shapeData, null, null, null);

            SetPhysicalProperties();
        });
        return;
    }
Пример #54
0
        public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying)
            : base(parent_scene, localID, avName, "BSCharacter")
        {
            _physicsActorType = (int)ActorTypes.Agent;
            _position         = pos;

            _flying          = isFlying;
            _orientation     = OMV.Quaternion.Identity;
            _velocity        = OMV.Vector3.Zero;
            _buoyancy        = ComputeBuoyancyFromFlying(isFlying);
            _currentFriction = BSParam.AvatarStandingFriction;
            _avatarDensity   = 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();

            SetupMovementMotor();

            DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}",
                      LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);

            // do actual creation in taint time
            PhysicsScene.TaintedObject("BSCharacter.create", delegate()
            {
                DetailLog("{0},BSCharacter.create,taint", LocalID);
                // New body and shape into PhysBody and PhysShape
                PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this);

                SetPhysicalProperties();
            });
            return;
        }
Пример #55
0
        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;

            parent.ClearDisplacement();
        }
Пример #56
0
        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;

            // The collection of things that push me around
            PhysicalActors = new BSActorCollection(PhysScene);

            // Initialize variables kept in base.
            GravModifier = 1.0f;
            Gravity      = new OMV.Vector3(0f, 0f, BSParam.Gravity);
            HoverActive  = false;

            // We don't have any physical representation yet.
            PhysBody  = new BulletBody(localID);
            PhysShape = new BSShapeNull();

            UserSetCenterOfMassDisplacement = null;

            PrimAssetState = PrimAssetCondition.Unknown;

            // Default material type. Also sets Friction, Restitution and Density.
            SetMaterial((int)MaterialAttributes.Material.Wood);

            CollisionCollection    = new CollisionEventUpdate();
            CollisionsLastReported = CollisionCollection;
            CollisionsLastTick     = new CollisionEventUpdate();
            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;
        }
Пример #57
0
        public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
            OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, int material, float friction,
            float restitution, float gravityMultiplier, float density)
            : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
        {
            Linkset = BSLinkset.Factory(PhysicsScene, this);

            PhysicsScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
            {
            base.SetMaterial(material);
            base.Friction = friction;
            base.Restitution = restitution;
            base.GravityMultiplier = gravityMultiplier;
            base.Density = density;
            Linkset.Refresh(this);
            });
        }
Пример #58
0
        public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
                              OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, int material, float friction,
                              float restitution, float gravityMultiplier, float density)
            : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
        {
            Linkset = BSLinkset.Factory(PhysicsScene, this);

            PhysicsScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
            {
                base.SetMaterial(material);
                base.Friction          = friction;
                base.Restitution       = restitution;
                base.GravityMultiplier = gravityMultiplier;
                base.Density           = density;
                Linkset.Refresh(this);
            });
        }
Пример #59
0
    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;
    }
Пример #60
0
 // 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);
     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();
 }