Esempio n. 1
0
        public override void Initialize(IMesher meshmerizer, IConfigSource config, UUID regionId)
        {
            // Does nothing much right now
            _mesher = meshmerizer;

            //fire up our work loop
            HeartbeatThread = Watchdog.StartThread(new ThreadStart(Heartbeat), "Physics Heartbeat",
                ThreadPriority.Normal, false);

            TimingThread = Watchdog.StartThread(new ThreadStart(DoTiming), string.Format("Physics Timing"),
                ThreadPriority.Highest, false);
        }
Esempio n. 2
0
        public static GameObject CreateWorld(string name, long seed, WorldGenerator<VoxelData> worldGenerator, IMesher mesher)
        {
            GameObject ob = new GameObject("World-" + name, typeof(Terrain.World));
            ob.transform.position = Vector3.zero;
            ob.transform.rotation = Quaternion.identity;

            Terrain.World world = ob.GetComponent<Terrain.World>();
            world.Seed = seed;
            world.Mesher = mesher;
            world.WorldGenerator = worldGenerator;
            world.GenerateWorld();

            LoadedWorlds[name] = ob;
            return ob;
        }
Esempio n. 3
0
 public override void Initialise(IMesher meshmerizer, IConfigSource config)
 {
 }
Esempio n. 4
0
        public static GameObject CreateWorld(string name, long seed, WorldGenerator <VoxelData> worldGenerator, IMesher mesher)
        {
            GameObject ob = new GameObject("World-" + name, typeof(Terrain.World));

            ob.transform.position = Vector3.zero;
            ob.transform.rotation = Quaternion.identity;

            Terrain.World world = ob.GetComponent <Terrain.World>();
            world.Seed           = seed;
            world.Mesher         = mesher;
            world.WorldGenerator = worldGenerator;
            world.GenerateWorld();

            LoadedWorlds[name] = ob;
            return(ob);
        }
 // Initialize the mesh plugin
 public override void Initialize(IMesher meshmerizer, IScene scene)
 {
     mesher = meshmerizer;
     m_region = scene.RegionInfo;
     m_scene = scene;
     WorldExtents = new Vector2(m_region.RegionSizeX, m_region.RegionSizeY);
 }
 public abstract void Initialise(IMesher meshmerizer, IScene scene);
Esempio n. 7
0
        public override void Initialise(IMesher meshmerizer, IConfigSource config)
        {
            mesher = meshmerizer;
            //m_config = config;
            if (config != null)
            {
                IConfig physicsconfig = config.Configs["BulletPhysicsSettings"];
                if (physicsconfig != null)
                {
                    gravityx = physicsconfig.GetFloat("world_gravityx", 0f);
                    gravityy = physicsconfig.GetFloat("world_gravityy", 0f);
                    gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f);

                    avDensity = physicsconfig.GetFloat("av_density", 80f);
                    avHeightFudgeFactor = physicsconfig.GetFloat("av_height_fudge_factor", 0.52f);
                    avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f);
                    avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f);
                    avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);

                    //contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80);

                    geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 4);

                    geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f);
                    bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20);

                    bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f);
                    bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f);

                    meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true);
                    meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f);
                    MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f);

                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 65f);
                        avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 25);
                        avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 2000000f);
                        bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_linux", 2f);
                    }
                    else
                    {
                        avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 65f);
                        avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 25);
                        avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 2000000f);
                        bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 2f);
                    }

                    forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing);
                    minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
                    maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f);
                }
            }
            lock (BulletLock)
            {
                m_broadphase = new btAxisSweep3(worldAabbMin, worldAabbMax, 16000);
                m_collisionConfiguration = new btDefaultCollisionConfiguration();
                m_solver = new btSequentialImpulseConstraintSolver();
                m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
                m_world = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
                m_world.setGravity(m_gravity);
                EnableCollisionInterface();
            }
        }
Esempio n. 8
0
 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
Esempio n. 9
0
 public override void Initialise(IMesher meshmerizer, IConfigSource config)
 {
     throw new Exception("Should not be called.");
 }
Esempio n. 10
0
        // Initializes the physics scene
        /// <summary>
        /// Initializes the physics scene.
        /// </summary>
        /// <param name="meshmerizer">The mesher to be used for creating
        /// meshes from shape descriptions</param>
        /// <param name="config">The configuration settings to be used to
        /// configure the scene</param>
        /// <param name="regionExtent">The size of the scene in Open Simulator
        /// units</param>
        public override void Initialise(IMesher meshmerizer,
                                        IConfigSource config, Vector3 regionExtent)
        {
            OpenMetaverse.Vector3 gravityVector;

            // Create a configuration, which will be used for initializing the
            // scene, using the "RemotePhysics" section of the given
            // configuration file
            RemoteConfiguration.Initialize(config.Configs["RemotePhysics"]);

            // Initialize the dimensions of this scene
            m_regionExtents = regionExtent;

            // Initialize the mesher
            SceneMesher = meshmerizer;

            // Create the dictionary that will map physics objects to their
            // respective IDs
            PhysicsObjects = new Dictionary <uint, RemotePhysicsObject>();

            // Create the dictionaries that keep track of which objects have
            // collisions or don't have collisions
            ObjectsWithCollisions       = new HashSet <RemotePhysicsObject>();
            ObjectsWithNoMoreCollisions = new HashSet <RemotePhysicsObject>();

            // The simulation time has not been updated yet
            m_lastSimulatedTime = 0.0f;

            // Create the packet manager that will maintain a connection
            // with the remote physics server
            m_remotePacketManager =
                new RemotePhysicsTCPPacketManager(RemoteConfiguration);

            // Create the packet manager that will be used for UDP
            // communications with the remote physics server
            m_remoteUdpPacketManager =
                new RemotePhysicsUDPPacketManager(RemoteConfiguration);

            // Create the messaging system that will allow this scene to
            // communicate with the remote physics server
            m_remoteMessenger = new RemotePhysicsAPPMessenger();
            m_remoteMessenger.Initialize(RemoteConfiguration,
                                         m_remotePacketManager, m_remoteUdpPacketManager);
            RemoteMessenger = m_remoteMessenger;

            // Initialize the lists that will track which objects were updated
            // duing this and the last step
            m_updatedObjects     = new List <RemotePhysicsObject>();
            m_lastUpdatedObjects = new List <RemotePhysicsObject>();

            // Send the logon message
            m_remoteMessenger.Logon(RemoteConfiguration.SimulationID,
                                    RegionName);

            // Set the callbacks that listen for updates from the remote engine
            m_remoteMessenger.OnDynamicActorUpdateEvent +=
                new UpdateDynamicActorHandler(DynamicActorUpdated);
            m_remoteMessenger.OnActorsCollidedEvent +=
                new ActorsCollidedHandler(ActorsCollided);
            m_remoteMessenger.OnDynamicActorMassUpdateEvent +=
                new UpdateDynamicActorMassHandler(ActorMassUpdated);
            m_remoteMessenger.OnTimeAdvancedEvent +=
                new TimeAdvancedHandler(TimeAdvanced);

            // Send the message to the remote physics engine that creates
            // the remote scene and establishes the ground plane
            gravityVector = new OpenMetaverse.Vector3(0.0f, 0.0f,
                                                      RemoteConfiguration.Gravity);
            m_remoteMessenger.InitializeWorld(gravityVector,
                                              RemoteConfiguration.DefaultFriction,
                                              RemoteConfiguration.DefaultFriction,
                                              RemoteConfiguration.CollisionMargin,
                                              RemoteConfiguration.DefaultRestitution, m_groundPlaneID,
                                              RemoteConfiguration.GroundPlaneHeight,
                                              new OpenMetaverse.Vector3(0.0f, 0.0f, 1.0f));

            // Indicate that the scene is now initialized
            m_initialized = true;
        }
Esempio n. 11
0
        public override void Initialise(IMesher meshmerizer, IConfigSource config)
        {
            mesher               = meshmerizer;
            _taintOperations     = new List <TaintCallbackEntry>();
            _postTaintOperations = new Dictionary <string, TaintCallbackEntry>();
            _postStepOperations  = new List <TaintCallbackEntry>();
            PhysObjects          = new Dictionary <uint, BSPhysObject>();
            Shapes               = new BSShapeCollection(this);

            // Allocate pinned memory to pass parameters.
            UnmanagedParams = new ConfigurationParameters[1];
            //m_paramsHandle = GCHandle.Alloc(UnmanagedParams, GCHandleType.Pinned);

            // Set default values for physics parameters plus any overrides from the ini file
            GetInitialParameterValues(config);

            // allocate more pinned memory close to the above in an attempt to get the memory all together
            m_collisionArray = new List <BulletXNA.CollisionDesc>();
            //m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned);
            m_updateArray = new List <BulletXNA.EntityProperties>();
            //m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned);

            // Enable very detailed logging.
            // By creating an empty logger when not logging, the log message invocation code
            //     can be left in and every call doesn't have to check for null.
            if (m_physicsLoggingEnabled)
            {
                PhysicsLogging             = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes);
                PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages.
            }
            else
            {
                PhysicsLogging = new Logging.LogWriter();
            }

            // If Debug logging level, enable logging from the unmanaged code
            m_DebugLogCallbackHandle = null;
            if (m_log.IsDebugEnabled || PhysicsLogging.Enabled)
            {
                m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
                if (PhysicsLogging.Enabled)
                {
                    // The handle is saved in a variable to make sure it doesn't get freed after this call
                    m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog);
                }
                else
                {
                    m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
                }
            }

            // Get the version of the DLL
            // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
            // BulletSimVersion = BulletSimAPI.GetVersion();
            // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion);

            // The bounding box for the simulated world. The origin is 0,0,0 unless we're
            //    a child in a mega-region.
            // Bullet actually doesn't care about the extents of the simulated
            //    area. It tracks active objects no matter where they are.
            Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);

            // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);

            World = new BulletWorld(0, this, BulletSimAPI.Initialize2(worldExtent, UnmanagedParams,
                                                                      m_maxCollisionsPerFrame, ref m_collisionArray,
                                                                      m_maxUpdatesPerFrame, ref m_updateArray,
                                                                      m_DebugLogCallbackHandle));

            Constraints = new BSConstraintCollection(World);

            TerrainManager = new BSTerrainManager(this);
            TerrainManager.CreateInitialGroundPlaneAndTerrain();

            m_log.WarnFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);

            InTaintTime   = false;
            m_initialized = true;
        }
Esempio n. 12
0
        public override void Initialize(IMesher meshmerizer, Nini.Config.IConfigSource config, OpenMetaverse.UUID regionId)
        {
            _regionId = regionId;
            _mesher   = meshmerizer;

            m_log.Info("[InWorldz.PhysxPhysics] Creating PhysX scene");

            if (config.Configs["InWorldz.PhysxPhysics"] != null)
            {
                Settings.Instance.UseVisualDebugger = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_visual_debugger", false);
                Settings.Instance.UseCCD            = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_ccd", true);
                Settings.Instance.Gravity           = config.Configs["InWorldz.PhysxPhysics"].GetFloat("gravity", -9.8f);
                Settings.Instance.ThrowOnSdkError   = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("throw_on_sdk_error", false);
                Settings.Instance.InstrumentMeshing = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("instrument_meshing", false);
            }
            else
            {
                Settings.Instance.UseVisualDebugger = false;
                Settings.Instance.UseCCD            = true;
                Settings.Instance.Gravity           = -9.8f;
                Settings.Instance.ThrowOnSdkError   = false;
                Settings.Instance.InstrumentMeshing = false;
            }

            Nini.Config.IConfig startupcfg = config.Configs["Startup"];
            if (startupcfg != null)
            {
                _gridmode = startupcfg.GetBoolean("gridmode", true);
            }

            if (_foundation == null)
            {
                _foundation = new PhysX.Foundation(s_ErrorCallback);
                _physics    = new PhysX.Physics(_foundation);

                Material.BuiltinMaterialInit(_physics);
            }

            _sceneDesc         = new PhysX.SceneDesc(null, Settings.Instance.UseCCD);
            _sceneDesc.Gravity = new PhysX.Math.Vector3(0f, 0f, Settings.Instance.Gravity);


            _simEventDelegator = new SimulationEventCallbackDelegator();
            _simEventDelegator.OnContactCallback += this.OnContact;
            _simEventDelegator.OnTriggerCallback += this.OnTrigger;
            _sceneDesc.SimulationEventCallback    = _simEventDelegator;

            _scene = _physics.CreateScene(_sceneDesc);
            Preload();

            if (Settings.Instance.UseCCD)
            {
                _scene.SetFlag(PhysX.SceneFlag.SweptIntegration, true);
            }

            if (Settings.Instance.UseVisualDebugger && _physics.RemoteDebugger != null)
            {
                _physics.RemoteDebugger.Connect("localhost", null, null, PhysX.VisualDebugger.VisualDebuggerConnectionFlag.Debug, null);
            }

            _controllerManager = _scene.CreateControllerManager();

            CreateDefaults();

            _terrainMesher = new Meshing.TerrainMesher(_scene);
            _terrainMgr    = new TerrainManager(_scene, _terrainMesher, regionId);
            _meshingStage  = new Meshing.MeshingStage(_scene, meshmerizer, _terrainMesher);
            _meshingStage.OnShapeNeedsFreeing += new Meshing.MeshingStage.ShapeNeedsFreeingDelegate(_meshingStage_OnShapeNeedsFreeing);

            _kinematicManager = new KinematicManager();

            //fire up our work loop
            HeartbeatThread = Watchdog.StartThread(new ThreadStart(Heartbeat), "Physics Heartbeat",
                                                   ThreadPriority.Normal, false);

            TimingThread = Watchdog.StartThread(new ThreadStart(DoTiming), string.Format("Physics Timing"),
                                                ThreadPriority.Highest, false);
        }
Esempio n. 13
0
 public abstract void Initialise(IMesher meshmerizer, RegionInfo region);
Esempio n. 14
0
 public static GameObject CreateWorld(string name, WorldGenerator <VoxelData> WorldGenerator, IMesher mesher)
 {
     return(CreateWorld(name, 0, WorldGenerator, mesher));
 }
Esempio n. 15
0
 public override void Initialise(IMesher meshmerizer, RegionInfo region, IRegistryCore registry)
 {
     m_region = region;
 }
Esempio n. 16
0
        // Initialize the mesh plugin
        public override void Initialise(IMesher meshmerizer, IConfigSource config)
        {
            mesher = meshmerizer;
            m_config = config;
            // Defaults

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                avPIDD = 3200.0f;
                avPIDP = 1400.0f;
                avStandupTensor = 2000000f;
            }
            else
            {
                avPIDD = 2200.0f;
                avPIDP = 900.0f;
                avStandupTensor = 550000f;
            }

            int contactsPerCollision = 80;

            if (m_config != null)
            {
                IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"];
                if (physicsconfig != null)
                {
                    gravityx = physicsconfig.GetFloat("world_gravityx", 0f);
                    gravityy = physicsconfig.GetFloat("world_gravityy", 0f);
                    gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f);

                    worldHashspaceLow = physicsconfig.GetInt("world_hashspace_size_low", -4);
                    worldHashspaceHigh = physicsconfig.GetInt("world_hashspace_size_high", 128);

                    metersInSpace = physicsconfig.GetFloat("meters_in_small_space", 29.9f);
                    smallHashspaceLow = physicsconfig.GetInt("small_hashspace_size_low", -4);
                    smallHashspaceHigh = physicsconfig.GetInt("small_hashspace_size_high", 66);

                    contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", 0.001f);

                    nmTerrainContactFriction = physicsconfig.GetFloat("nm_terraincontact_friction", 255.0f);
                    nmTerrainContactBounce = physicsconfig.GetFloat("nm_terraincontact_bounce", 0.1f);
                    nmTerrainContactERP = physicsconfig.GetFloat("nm_terraincontact_erp", 0.1025f);

                    mTerrainContactFriction = physicsconfig.GetFloat("m_terraincontact_friction", 75f);
                    mTerrainContactBounce = physicsconfig.GetFloat("m_terraincontact_bounce", 0.05f);
                    mTerrainContactERP = physicsconfig.GetFloat("m_terraincontact_erp", 0.05025f);

                    nmAvatarObjectContactFriction = physicsconfig.GetFloat("objectcontact_friction", 250f);
                    nmAvatarObjectContactBounce = physicsconfig.GetFloat("objectcontact_bounce", 0.2f);

                    mAvatarObjectContactFriction = physicsconfig.GetFloat("m_avatarobjectcontact_friction", 75f);
                    mAvatarObjectContactBounce = physicsconfig.GetFloat("m_avatarobjectcontact_bounce", 0.1f);

                    ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f);
                    m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10);

                    avDensity = physicsconfig.GetFloat("av_density", 80f);
                    avHeightFudgeFactor = physicsconfig.GetFloat("av_height_fudge_factor", 0.52f);
                    avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f);
                    avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f);
                    avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);
                    avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false);

                    contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80);

                    geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
                    geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
                    geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);

                    geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f);
                    bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20);

                    bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f);
                    bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f);

                    forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing);
                    meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true);
                    meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f);
                    MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f);
                    m_filterCollisions = physicsconfig.GetBoolean("filter_collisions", false);

                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f);
                        avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f);
                        avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 550000f);
                        bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_linux", 5f);
                    }
                    else
                    {
                        avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f);
                        avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f);
                        avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f);
                        bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 5f);
                    }

                    physics_logging = physicsconfig.GetBoolean("physics_logging", false);
                    physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0);
                    physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false);

                    m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false);
                    minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
                    maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f);
                }
            }

            contacts = new d.ContactGeom[contactsPerCollision];

            staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)];

            // Centeral contact friction and bounce
            // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why
            // an avatar falls through in Z but not in X or Y when walking on a prim.
            contact.surface.mode |= d.ContactFlags.SoftERP;
            contact.surface.mu = nmAvatarObjectContactFriction;
            contact.surface.bounce = nmAvatarObjectContactBounce;
            contact.surface.soft_cfm = 0.010f;
            contact.surface.soft_erp = 0.010f;

            // Terrain contact friction and Bounce
            // This is the *non* moving version.   Use this when an avatar
            // isn't moving to keep it in place better
            TerrainContact.surface.mode |= d.ContactFlags.SoftERP;
            TerrainContact.surface.mu = nmTerrainContactFriction;
            TerrainContact.surface.bounce = nmTerrainContactBounce;
            TerrainContact.surface.soft_erp = nmTerrainContactERP;

            WaterContact.surface.mode |= (d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM);
            WaterContact.surface.mu = 0f; // No friction
            WaterContact.surface.bounce = 0.0f; // No bounce
            WaterContact.surface.soft_cfm = 0.010f;
            WaterContact.surface.soft_erp = 0.010f;

            // Prim contact friction and bounce
            // THis is the *non* moving version of friction and bounce
            // Use this when an avatar comes in contact with a prim
            // and is moving
            AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction;
            AvatarMovementprimContact.surface.bounce = mAvatarObjectContactBounce;

            // Terrain contact friction bounce and various error correcting calculations
            // Use this when an avatar is in contact with the terrain and moving.
            AvatarMovementTerrainContact.surface.mode |= d.ContactFlags.SoftERP;
            AvatarMovementTerrainContact.surface.mu = mTerrainContactFriction;
            AvatarMovementTerrainContact.surface.bounce = mTerrainContactBounce;
            AvatarMovementTerrainContact.surface.soft_erp = mTerrainContactERP;


            /*
                <summary></summary>
                Stone = 0,
                /// <summary></summary>
                Metal = 1,
                /// <summary></summary>
                Glass = 2,
                /// <summary></summary>
                Wood = 3,
                /// <summary></summary>
                Flesh = 4,
                /// <summary></summary>
                Plastic = 5,
                /// <summary></summary>
                Rubber = 6
             */

            m_materialContacts = new d.Contact[7,2];

            m_materialContacts[(int)Material.Stone, 0] = new d.Contact();
            m_materialContacts[(int)Material.Stone, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Stone, 0].surface.mu = nmAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Stone, 0].surface.bounce = nmAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Stone, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Stone, 0].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Stone, 1] = new d.Contact();
            m_materialContacts[(int)Material.Stone, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Stone, 1].surface.mu = mAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Stone, 1].surface.bounce = mAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Stone, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Stone, 1].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Metal, 0] = new d.Contact();
            m_materialContacts[(int)Material.Metal, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Metal, 0].surface.mu = nmAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Metal, 0].surface.bounce = nmAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Metal, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Metal, 0].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Metal, 1] = new d.Contact();
            m_materialContacts[(int)Material.Metal, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Metal, 1].surface.mu = mAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Metal, 1].surface.bounce = mAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Metal, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Metal, 1].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Glass, 0] = new d.Contact();
            m_materialContacts[(int)Material.Glass, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Glass, 0].surface.mu = 1f;
            m_materialContacts[(int)Material.Glass, 0].surface.bounce = 0.5f;
            m_materialContacts[(int)Material.Glass, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Glass, 0].surface.soft_erp = 0.010f;

            /*
                private float nmAvatarObjectContactFriction = 250f;
                private float nmAvatarObjectContactBounce = 0.1f;

                private float mAvatarObjectContactFriction = 75f;
                private float mAvatarObjectContactBounce = 0.1f;
            */
            m_materialContacts[(int)Material.Glass, 1] = new d.Contact();
            m_materialContacts[(int)Material.Glass, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Glass, 1].surface.mu = 1f;
            m_materialContacts[(int)Material.Glass, 1].surface.bounce = 0.5f;
            m_materialContacts[(int)Material.Glass, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Glass, 1].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Wood, 0] = new d.Contact();
            m_materialContacts[(int)Material.Wood, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Wood, 0].surface.mu = nmAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Wood, 0].surface.bounce = nmAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Wood, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Wood, 0].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Wood, 1] = new d.Contact();
            m_materialContacts[(int)Material.Wood, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Wood, 1].surface.mu = mAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Wood, 1].surface.bounce = mAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Wood, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Wood, 1].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Flesh, 0] = new d.Contact();
            m_materialContacts[(int)Material.Flesh, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Flesh, 0].surface.mu = nmAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Flesh, 0].surface.bounce = nmAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Flesh, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Flesh, 0].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Flesh, 1] = new d.Contact();
            m_materialContacts[(int)Material.Flesh, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Flesh, 1].surface.mu = mAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Flesh, 1].surface.bounce = mAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Flesh, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Flesh, 1].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Plastic, 0] = new d.Contact();
            m_materialContacts[(int)Material.Plastic, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Plastic, 0].surface.mu = nmAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Plastic, 0].surface.bounce = nmAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Plastic, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Plastic, 0].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Plastic, 1] = new d.Contact();
            m_materialContacts[(int)Material.Plastic, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Plastic, 1].surface.mu = mAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Plastic, 1].surface.bounce = mAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Plastic, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Plastic, 1].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Rubber, 0] = new d.Contact();
            m_materialContacts[(int)Material.Rubber, 0].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Rubber, 0].surface.mu = nmAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Rubber, 0].surface.bounce = nmAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Rubber, 0].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Rubber, 0].surface.soft_erp = 0.010f;

            m_materialContacts[(int)Material.Rubber, 1] = new d.Contact();
            m_materialContacts[(int)Material.Rubber, 1].surface.mode |= d.ContactFlags.SoftERP;
            m_materialContacts[(int)Material.Rubber, 1].surface.mu = mAvatarObjectContactFriction;
            m_materialContacts[(int)Material.Rubber, 1].surface.bounce = mAvatarObjectContactBounce;
            m_materialContacts[(int)Material.Rubber, 1].surface.soft_cfm = 0.010f;
            m_materialContacts[(int)Material.Rubber, 1].surface.soft_erp = 0.010f;

            d.HashSpaceSetLevels(space, worldHashspaceLow, worldHashspaceHigh);

            // Set the gravity,, don't disable things automatically (we set it explicitly on some things)

            d.WorldSetGravity(world, gravityx, gravityy, gravityz);
            d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);

            d.WorldSetLinearDamping(world, 256f);
            d.WorldSetAngularDamping(world, 256f);
            d.WorldSetAngularDampingThreshold(world, 256f);
            d.WorldSetLinearDampingThreshold(world, 256f);
            d.WorldSetMaxAngularSpeed(world, 256f);

            // Set how many steps we go without running collision testing
            // This is in addition to the step size.
            // Essentially Steps * m_physicsiterations
            d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
            //d.WorldSetContactMaxCorrectingVel(world, 1000.0f);

            

            for (int i = 0; i < staticPrimspace.GetLength(0); i++)
            {
                for (int j = 0; j < staticPrimspace.GetLength(1); j++)
                {
                    staticPrimspace[i, j] = IntPtr.Zero;
                }
            }
        }
Esempio n. 17
0
 public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
 {
     m_regionExtent = regionExtent;
 }
Esempio n. 18
0
 public override void Initialise(IMesher meshmerizer, IScene scene)
 {
     m_region = scene.RegionInfo;
 }
Esempio n. 19
0
 public abstract void Initialize(IMesher meshmerizer, IConfigSource config, UUID regionId);
Esempio n. 20
0
        public override void Initialize(IMesher meshmerizer, IScene scene)
        {
            Scene = scene;
            mesher = meshmerizer;
            _taintOperations = new List<TaintCallbackEntry>();
            _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
            _postStepOperations = new List<TaintCallbackEntry>();
            PhysObjects = new Dictionary<uint, BSPhysObject>();
            Shapes = new BSShapeCollection(this);

            // some identifiers
            RegionName = scene.RegionInfo.RegionName;
            PhysicsSceneName = RegionName;

            // Allocate pinned memory to pass parameters.
            UnmanagedParams = new ConfigurationParameters[1];

            // Set default values for physics parameters plus any overrides from the ini file
            GetInitialParameterValues(scene.Config);

            // Get the connection to the physics engine (could be native or one of many DLLs)
            PE = SelectUnderlyingBulletEngine(BulletEngineName);

            // Enable very detailed logging.
            // By creating an empty logger when not logging, the log message invocation code
            //     can be left in and every call doesn't have to check for null.
            /*if (m_physicsLoggingEnabled)
            {
                PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes);
                PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages.
            }
            else
            {
                PhysicsLogging = new Logging.LogWriter();
            }*/

            // Allocate memory for returning of the updates and collisions from the physics engine
            m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
            m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];

            // The bounding box for the simulated world. The origin is 0,0,0 unless we're
            //    a child in a mega-region.
            // Bullet actually doesn't care about the extents of the simulated
            //    area. It tracks active objects no matter where they are.
            Vector3 worldExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeX, Constants.RegionHeight);
               // Vector3 worldExtent = regionExtent;

            World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray,
                m_maxUpdatesPerFrame, ref m_updateArray);

            Constraints = new BSConstraintCollection(World);

            TerrainManager = new BSTerrainManager(this);
            TerrainManager.CreateInitialGroundPlaneAndTerrain();

            MainConsole.Instance.WarnFormat("{0} Linksets implemented with {1}", LogHeader,
                (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);

            InTaintTime = false;
            m_initialized = true;
        }
Esempio n. 21
0
 public override void Initialise(IMesher meshmerizer, RegionInfo region)
 {
     mesher   = meshmerizer;
     m_region = region;
 }
Esempio n. 22
0
 public override void Initialise(IMesher meshmerizer, IConfigSource config)
 {
     mesher = meshmerizer;
     // m_config = config;
 }
Esempio n. 23
0
 // For older physics engines that do not implement non-legacy region sizes.
 // If the physics engine handles the region extent feature, it overrides this function.
 public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
 {
     // If not overridden, call the old initialization entry.
     Initialise(meshmerizer, config);
 }
Esempio n. 24
0
    public override void Initialise(IMesher meshmerizer, IConfigSource config)
    {
        mesher = meshmerizer;
        _taintOperations = new List<TaintCallbackEntry>();
        _postTaintOperations = new Dictionary<string, TaintCallbackEntry>();
        _postStepOperations = new List<TaintCallbackEntry>();
        PhysObjects = new Dictionary<uint, BSPhysObject>();
        Shapes = new BSShapeCollection(this);

        m_simulatedTime = 0f;
        LastTimeStep = 0.1f;

        // Allocate pinned memory to pass parameters.
        UnmanagedParams = new ConfigurationParameters[1];

        // Set default values for physics parameters plus any overrides from the ini file
        GetInitialParameterValues(config);

        // Get the connection to the physics engine (could be native or one of many DLLs)
        PE = SelectUnderlyingBulletEngine(BulletEngineName);

        // Enable very detailed logging.
        // By creating an empty logger when not logging, the log message invocation code
        //     can be left in and every call doesn't have to check for null.
        if (m_physicsLoggingEnabled)
        {
            PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes, m_physicsLoggingDoFlush);
            PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output its own error messages.
        }
        else
        {
            PhysicsLogging = new Logging.LogWriter();
        }

        // Allocate memory for returning of the updates and collisions from the physics engine
        m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
        m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];

        // The bounding box for the simulated world. The origin is 0,0,0 unless we're
        //    a child in a mega-region.
        // Bullet actually doesn't care about the extents of the simulated
        //    area. It tracks active objects no matter where they are.
        Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);

        World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray);

        Constraints = new BSConstraintCollection(World);

        TerrainManager = new BSTerrainManager(this);
        TerrainManager.CreateInitialGroundPlaneAndTerrain();

        // Put some informational messages into the log file.
        m_log.InfoFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);

        InTaintTime = false;
        m_initialized = true;

        // If the physics engine runs on its own thread, start same.
        if (BSParam.UseSeparatePhysicsThread)
        {
            // The physics simulation should happen independently of the heartbeat loop
            m_physicsThread = new Thread(BulletSPluginPhysicsThread);
            m_physicsThread.Name = BulletEngineName;
            m_physicsThread.Start();
        }
    }
Esempio n. 25
0
        public void RegionLoaded(Scene scene)
        {
            if (!m_Enabled)
                return;

            mesher = scene.RequestModuleInterface<IMesher>();
            if (mesher == null)
                m_log.WarnFormat("[ODE SCENE]: No mesher in {0}. Things will not work well.", PhysicsSceneName);
        }
Esempio n. 26
0
 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
Esempio n. 27
0
 // Old version of initialization that assumes legacy sized regions (256x256)
 public override void Initialise(IMesher meshmerizer, IConfigSource config)
 {
     m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up.");
     Vector3 regionExtent = new Vector3( Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
     Initialise(meshmerizer, config, regionExtent);
     
 }
Esempio n. 28
0
        public override void Initialise(IMesher meshmerizer, IScene scene)
        {
            Scene                = scene;
            mesher               = meshmerizer;
            _taintOperations     = new List <TaintCallbackEntry>();
            _postTaintOperations = new Dictionary <string, TaintCallbackEntry>();
            _postStepOperations  = new List <TaintCallbackEntry>();
            PhysObjects          = new Dictionary <uint, BSPhysObject>();
            Shapes               = new BSShapeCollection(this);

            // some identifiers
            RegionName       = scene.RegionInfo.RegionName;
            PhysicsSceneName = RegionName;

            // Allocate pinned memory to pass parameters.
            UnmanagedParams = new ConfigurationParameters[1];

            // Set default values for physics parameters plus any overrides from the ini file
            GetInitialParameterValues(scene.Config);

            // Get the connection to the physics engine (could be native or one of many DLLs)
            PE = SelectUnderlyingBulletEngine(BulletEngineName);
            if (PE == null)
            {
                MainConsole.Instance.Error("[BSScene]: Unable to select underlyin bullet engine!");
                return;
            }

            // Enable very detailed logging.
            // By creating an empty logger when not logging, the log message invocation code
            //     can be left in and every call doesn't have to check for null.

            /*if (m_physicsLoggingEnabled)
             * {
             *  PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes);
             *  PhysicsLogging.ErrorLogger = m_log; // for DEBUG. Let's the logger output error messages.
             * }
             * else
             * {
             *  PhysicsLogging = new Logging.LogWriter();
             * }*/

            // Allocate memory for returning of the updates and collisions from the physics engine
            m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
            m_updateArray    = new EntityProperties[m_maxUpdatesPerFrame];

            // The bounding box for the simulated world. The origin is 0,0,0 unless we're
            //    a child in a mega-region.
            // Bullet actually doesn't care about the extents of the simulated
            //    area. It tracks active objects no matter where they are.
            Vector3 worldExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeX, Constants.RegionHeight);

            // Vector3 worldExtent = regionExtent;

            World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray,
                                  m_maxUpdatesPerFrame, ref m_updateArray);

            Constraints = new BSConstraintCollection(World);

            TerrainManager = new BSTerrainManager(this);
            TerrainManager.CreateInitialGroundPlaneAndTerrain();

            MainConsole.Instance.WarnFormat("{0} Linksets implemented with {1}", LogHeader,
                                            (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);

            InTaintTime   = false;
            m_initialized = true;
        }
Esempio n. 29
0
 public override void Initialise (IMesher meshmerizer, RegionInfo region, IRegistryCore registry)
 {
     // Does nothing right now
 }
Esempio n. 30
0
 public static GameObject CreateWorld(string name, WorldGenerator<VoxelData> WorldGenerator, IMesher mesher)
 {
     return CreateWorld(name, 0, WorldGenerator, mesher);
 }
Esempio n. 31
0
 public abstract void Initialise (IMesher meshmerizer, RegionInfo region, IRegistryCore registry);
Esempio n. 32
0
        public override void Initialise(IMesher meshmerizer, IConfigSource config)
        {
            mesher = meshmerizer;
            // m_config = config;
            /*
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                m_log.Fatal("[BulletDotNET]: This configuration is not supported on *nix currently");
                Thread.Sleep(5000);
                Environment.Exit(0);
            }
            */
            m_broadphase = new btAxisSweep3(worldAabbMin, worldAabbMax, 16000);
            m_collisionConfiguration = new btDefaultCollisionConfiguration();
            m_solver = new btSequentialImpulseConstraintSolver();
            m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
            m_world = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
            m_world.setGravity(m_gravity);
            //EnableCollisionInterface();
            

        }
Esempio n. 33
0
 public void RegionLoaded()
 {
     mesher = m_frameWorkScene.RequestModuleInterface<IMesher>();
     if (mesher == null)
     {
         m_log.ErrorFormat("[ubOde] No mesher. module disabled");
         return;
     }
     
     m_meshWorker = new ODEMeshWorker(this, m_log, mesher, physicsconfig);
     m_frameWorkScene.PhysicsEnabled = true;
 }
Esempio n. 34
0
        // Initialize the mesh plugin
        public override void Initialise(IMesher meshmerizer, IConfigSource config, RegionInfo region )
        {
//            checkThread();
            mesher = meshmerizer;
            m_config = config;

//            m_log.WarnFormat("ODE configuration: {0}", d.GetConfiguration("ODE"));

            if (region != null)
            {
                WorldExtents.X = region.RegionSizeX;
                WorldExtents.Y = region.RegionSizeY;
            }
            // Defaults

            avPIDD = 2200.0f;
            avPIDP = 900.0f;

            int contactsPerCollision = 80;

            if (m_config != null)
            {
                IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"];
                if (physicsconfig != null)
                {
                    gravityx = physicsconfig.GetFloat("world_gravityx", 0f);
                    gravityy = physicsconfig.GetFloat("world_gravityy", 0f);
                    gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f);

                    metersInSpace = physicsconfig.GetFloat("meters_in_small_space", 29.9f);

                    contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer);

                    ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f);
                    m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10);

                    avDensity = physicsconfig.GetFloat("av_density", avDensity);
                    avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f);
                    avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f);
                    avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);

                    contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80);

                    geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
                    geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
                    geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);

                    geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f);
                    bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20);

                    bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f);
                    bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f);

                    forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing);
                    meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true);
                    meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f);
                    MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f);
                    m_filterCollisions = physicsconfig.GetBoolean("filter_collisions", false);

                    if (Environment.OSVersion.Platform == PlatformID.Unix)
                    {
                        avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f);
                        avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f);
                        bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_linux", 5f);
                    }
                    else
                    {
                        avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f);
                        avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f);
                        bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 5f);
                    }

                    physics_logging = physicsconfig.GetBoolean("physics_logging", false);
                    physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0);
                    physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false);

                    m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false);
                    minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
                    maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f);
                }
            }

            ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
            GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);

            m_materialContactsData[(int)Material.Stone].mu = frictionScale * 0.8f;
            m_materialContactsData[(int)Material.Stone].bounce = 0.4f;

            m_materialContactsData[(int)Material.Metal].mu = frictionScale * 0.3f;
            m_materialContactsData[(int)Material.Metal].bounce = 0.4f;

            m_materialContactsData[(int)Material.Glass].mu = frictionScale * 0.2f;
            m_materialContactsData[(int)Material.Glass].bounce = 0.7f;

            m_materialContactsData[(int)Material.Wood].mu = frictionScale * 0.6f;
            m_materialContactsData[(int)Material.Wood].bounce = 0.5f;

            m_materialContactsData[(int)Material.Flesh].mu = frictionScale * 0.9f;
            m_materialContactsData[(int)Material.Flesh].bounce = 0.3f;

            m_materialContactsData[(int)Material.Plastic].mu = frictionScale * 0.4f;
            m_materialContactsData[(int)Material.Plastic].bounce = 0.7f;

            m_materialContactsData[(int)Material.Rubber].mu = frictionScale * 0.9f;
            m_materialContactsData[(int)Material.Rubber].bounce = 0.95f;

            m_materialContactsData[(int)Material.light].mu = 0.0f;
            m_materialContactsData[(int)Material.light].bounce = 0.0f;

            TerrainFriction *= frictionScale;
//            AvatarFriction *= frictionScale;

            // Set the gravity,, don't disable things automatically (we set it explicitly on some things)

            d.WorldSetGravity(world, gravityx, gravityy, gravityz);
            d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);

            d.WorldSetLinearDamping(world, 0.002f);
            d.WorldSetAngularDamping(world, 0.002f);
            d.WorldSetAngularDampingThreshold(world, 0f);
            d.WorldSetLinearDampingThreshold(world, 0f);
            d.WorldSetMaxAngularSpeed(world, 256f);

            d.WorldSetCFM(world,1e-6f); // a bit harder than default
            //d.WorldSetCFM(world, 1e-4f); // a bit harder than default
            d.WorldSetERP(world, 0.6f); // higher than original

            // Set how many steps we go without running collision testing
            // This is in addition to the step size.
            // Essentially Steps * m_physicsiterations
            d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
            d.WorldSetContactMaxCorrectingVel(world, 100.0f);

            spacesPerMeter = 1 / metersInSpace;
            spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter);
            spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeter);

            staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY];

            // create all spaces now
            int i, j;
            IntPtr newspace;
            for (i = 0; i < spaceGridMaxX; i++)
                for (j = 0; j < spaceGridMaxY; j++)
                {
                    newspace = d.HashSpaceCreate(StaticSpace);
                    d.GeomSetCategoryBits(newspace, (int)CollisionCategories.Space);
                    waitForSpaceUnlock(newspace);
                    d.SpaceSetSublevel(newspace, 2);
                    d.HashSpaceSetLevels(newspace, -2, 8);
                    staticPrimspace[i, j] = newspace;
                }
            // let this now be real maximum values
            spaceGridMaxX--;
            spaceGridMaxY--;
        }
Esempio n. 35
0
        public override void Initialise(IMesher meshmerizer, IConfigSource config)
	    {
	        throw new System.NotImplementedException();
	    }
Esempio n. 36
0
    public override void Initialise(IMesher meshmerizer, IConfigSource config)
    {
        mesher = meshmerizer;
        _taintedObjects = new List<TaintCallbackEntry>();
        PhysObjects = new Dictionary<uint, BSPhysObject>();
        Shapes = new BSShapeCollection(this);

        // Allocate pinned memory to pass parameters.
        m_params = new ConfigurationParameters[1];
        m_paramsHandle = GCHandle.Alloc(m_params, GCHandleType.Pinned);

        // Set default values for physics parameters plus any overrides from the ini file
        GetInitialParameterValues(config);

        // allocate more pinned memory close to the above in an attempt to get the memory all together
        m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame];
        m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned);
        m_updateArray = new EntityProperties[m_maxUpdatesPerFrame];
        m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned);

        // Enable very detailed logging.
        // By creating an empty logger when not logging, the log message invocation code
        //     can be left in and every call doesn't have to check for null.
        if (m_physicsLoggingEnabled)
        {
            PhysicsLogging = new Logging.LogWriter(m_physicsLoggingDir, m_physicsLoggingPrefix, m_physicsLoggingFileMinutes);
        }
        else
        {
            PhysicsLogging = new Logging.LogWriter();
        }

        // If Debug logging level, enable logging from the unmanaged code
        m_DebugLogCallbackHandle = null;
        if (m_log.IsDebugEnabled || PhysicsLogging.Enabled)
        {
            m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
            if (PhysicsLogging.Enabled)
                // The handle is saved in a variable to make sure it doesn't get freed after this call
                m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog);
            else
                m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
        }

        // Get the version of the DLL
        // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
        // BulletSimVersion = BulletSimAPI.GetVersion();
        // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion);

        // The bounding box for the simulated world. The origin is 0,0,0 unless we're
        //    a child in a mega-region.
        // Turns out that Bullet really doesn't care about the extents of the simulated
        //    area. It tracks active objects no matter where they are.
        Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);

        // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);
        WorldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(),
                                        m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
                                        m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject(),
                                        m_DebugLogCallbackHandle);

        // Initialization to support the transition to a new API which puts most of the logic
        //   into the C# code so it is easier to modify and add to.
        World = new BulletSim(WorldID, this, BulletSimAPI.GetSimHandle2(WorldID));

        Constraints = new BSConstraintCollection(World);

        TerrainManager = new BSTerrainManager(this);
        TerrainManager.CreateInitialGroundPlaneAndTerrain();

        m_initialized = true;
    }
Esempio n. 37
0
 public override void Initialise(IMesher meshmerizer, RegionInfo region)
 {
     mesher = meshmerizer;
     m_region = region;
     _origheightmap = new float[m_region.RegionSizeX * m_region.RegionSizeY];
 }
Esempio n. 38
0
 public override void Initialise(IMesher meshmerizer, RegionInfo region)
 {
     m_region = region;
 }
Esempio n. 39
0
 public abstract void Initialise(IMesher meshmerizer, IScene scene);
Esempio n. 40
0
 // Initialize the mesh plugin
 public override void Initialise(IMesher meshmerizer, RegionInfo region, IRegistryCore registry)
 {
     mesher = meshmerizer;
     m_region = region;
     m_registry = registry;
     WorldExtents = new Vector2(region.RegionSizeX, region.RegionSizeY);
 }
Esempio n. 41
0
 public override void Initialise(IMesher meshmerizer, IScene scene)
 {
     // Does nothing right now
 }
 public override void Initialise(IMesher meshmerizer, IScene scene)
 {
     // Does nothing right now
 }
Esempio n. 43
0
 public override void Initialise(IMesher meshmerizer, IConfigSource config)
 {
 }
Esempio n. 44
0
 public override void Initialize(IMesher meshmerizer, IScene scene)
 {
     m_region = scene.RegionInfo;
 }
Esempio n. 45
0
 public override void Initialise(IMesher meshmerizer, RegionInfo region, IRegistryCore registry)
 {
     m_region = region;
 }
Esempio n. 46
0
 public override void Initialise(IMesher meshmerizer, IVoxelMesher derp, IConfigSource config)
 {
     // Does nothing right now
 }
Esempio n. 47
0
 public override void Initialise(IMesher meshmerizer, IConfigSource config)
 {
     // Does nothing right now
 }
Esempio n. 48
0
 public abstract void Initialise(IMesher meshmerizer, RegionInfo region, IRegistryCore registry);
Esempio n. 49
0
        public override void Initialize(IMesher meshmerizer, Nini.Config.IConfigSource config, OpenMetaverse.UUID regionId)
        {
            _regionId = regionId;
            _mesher = meshmerizer;

            m_log.Info("[InWorldz.PhysxPhysics] Creating PhysX scene");

            if (config.Configs["InWorldz.PhysxPhysics"] != null)
            {
                Settings.Instance.UseVisualDebugger = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_visual_debugger", false);
                Settings.Instance.UseCCD = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_ccd", true);
                Settings.Instance.Gravity = config.Configs["InWorldz.PhysxPhysics"].GetFloat("gravity", -9.8f);
                Settings.Instance.ThrowOnSdkError = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("throw_on_sdk_error", false);
                Settings.Instance.InstrumentMeshing = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("instrument_meshing", false);
            }
            else
            {
                Settings.Instance.UseVisualDebugger = false;
                Settings.Instance.UseCCD = true;
                Settings.Instance.Gravity = -9.8f;
                Settings.Instance.ThrowOnSdkError = false;
                Settings.Instance.InstrumentMeshing = false;
            }

            Nini.Config.IConfig startupcfg = config.Configs["Startup"];
            if (startupcfg != null)
                _gridmode = startupcfg.GetBoolean("gridmode", false);

            if (_foundation == null)
            {
                _foundation = new PhysX.Foundation(s_ErrorCallback);
                _physics = new PhysX.Physics(_foundation);

                Material.BuiltinMaterialInit(_physics);
            }

            _sceneDesc = new PhysX.SceneDesc(null, Settings.Instance.UseCCD);
            _sceneDesc.Gravity = new PhysX.Math.Vector3(0f, 0f, Settings.Instance.Gravity);


            _simEventDelegator = new SimulationEventCallbackDelegator();
            _simEventDelegator.OnContactCallback += this.OnContact;
            _simEventDelegator.OnTriggerCallback += this.OnTrigger;
            _sceneDesc.SimulationEventCallback = _simEventDelegator;

            _scene = _physics.CreateScene(_sceneDesc);
            Preload();

            if (Settings.Instance.UseCCD)
            {
                _scene.SetFlag(PhysX.SceneFlag.SweptIntegration, true);
            }

            if (Settings.Instance.UseVisualDebugger && _physics.RemoteDebugger != null)
            {
                _physics.RemoteDebugger.Connect("localhost", null, null, PhysX.VisualDebugger.VisualDebuggerConnectionFlag.Debug, null);
            }

            _controllerManager = _scene.CreateControllerManager();

            CreateDefaults();

            _terrainMesher = new Meshing.TerrainMesher(_scene);
            _terrainMgr = new TerrainManager(_scene, _terrainMesher, regionId);
            _meshingStage = new Meshing.MeshingStage(_scene, meshmerizer, _terrainMesher);
            _meshingStage.OnShapeNeedsFreeing += new Meshing.MeshingStage.ShapeNeedsFreeingDelegate(_meshingStage_OnShapeNeedsFreeing);

            _kinematicManager = new KinematicManager();

            //fire up our work loop
            HeartbeatThread = Watchdog.StartThread(new ThreadStart(Heartbeat), "Physics Heartbeat",
                ThreadPriority.Normal, false);

            TimingThread = Watchdog.StartThread(new ThreadStart(DoTiming), string.Format("Physics Timing"),
                ThreadPriority.Highest, false);
        }
Esempio n. 50
0
 public override void Initialise(IMesher meshmerizer, RegionInfo region, IRegistryCore registry)
 {
     // Does nothing right now
 }