public override void PostInitialise(IConfigSource config) { m_rayCastManager = new AuroraODERayCastRequestManager(this); RemoveQueue = new List<PhysicsObject>(); DeleteQueue = new List<PhysicsObject>(); m_config = config; // Defaults /* if (Environment.OSVersion.Platform == PlatformID.Unix) { PID_D = 3200.0f; PID_P = 1400.0f; } else { */ PID_D = 2200.0f; PID_P = 900.0f; // } if (m_config != null) { IConfig physicsconfig = m_config.Configs["AuroraODEPhysicsSettings"]; if (physicsconfig != null) { gravityx = physicsconfig.GetFloat("world_gravityx", 0f); gravityy = physicsconfig.GetFloat("world_gravityy", 0f); gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); //Set the vectors as well gravityVector = new Vector3(gravityx, gravityy, gravityz); gravityVectorNormalized = gravityVector; gravityVectorNormalized.Normalize(); m_avDecayTime = physicsconfig.GetFloat("avDecayTime", m_avDecayTime); m_avStopDecaying = physicsconfig.GetFloat("avStopDecaying", m_avStopDecaying); AllowUnderwaterPhysics = physicsconfig.GetBoolean("useUnderWaterPhysics", false); AllowAvGravity = physicsconfig.GetBoolean("useAvGravity", true); AvGravityHeight = physicsconfig.GetInt("avGravityHeight", 4096); AllowAvsToEscapeGravity = physicsconfig.GetBoolean("aviesCanEscapeGravity", true); m_AvFlySpeed = physicsconfig.GetFloat("AvFlySpeed", m_AvFlySpeed); m_allowJump = physicsconfig.GetBoolean("AllowJump", m_allowJump); m_usepreJump = physicsconfig.GetBoolean("UsePreJump", m_usepreJump); m_preJumpTime = physicsconfig.GetInt("PreJumpTime", m_preJumpTime); m_preJumpForceMultiplierX = physicsconfig.GetFloat("PreJumpMultiplierX", m_preJumpForceMultiplierX); m_preJumpForceMultiplierY = physicsconfig.GetFloat("PreJumpMultiplierY", m_preJumpForceMultiplierY); m_preJumpForceMultiplierZ = physicsconfig.GetFloat("PreJumpMultiplierZ", m_preJumpForceMultiplierZ); contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", 0.001f); AvatarContactBounce = physicsconfig.GetFloat("AvatarContactBounce", AvatarContactBounce); FrictionMovementMultiplier = physicsconfig.GetFloat("FrictionMovementMultiplier", FrictionMovementMultiplier); FrictionScale = physicsconfig.GetFloat("FrictionMovementMultiplier", FrictionScale); 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("WalkSpeed", 1.3f)*2); avMovementDivisorRun = (physicsconfig.GetFloat("RunSpeed", 0.8f)*2); 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", 10); 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) { PID_D = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f); PID_P = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f); } else { PID_D = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); PID_P = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); } 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_useFlightCeilingHeight = physicsconfig.GetBoolean("Use_Flight_Ceiling_Height_Max", m_useFlightCeilingHeight); m_flightCeilingHeight = physicsconfig.GetFloat("Flight_Ceiling_Height_Max", m_flightCeilingHeight); //Rex minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 100000.01f); DoPhyWind = physicsconfig.GetBoolean("do_physics_wind", false); } } lock (OdeLock) { // alloc unmanaged memory to receive information from colision contact joints ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision*d.ContactGeom.unmanagedSizeOf); // alloc unmanaged memory to pass information to colision contact joints GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath*d.Contact.unmanagedSizeOf); newGlobalcontact.surface.mode = CommumContactFlags; newGlobalcontact.surface.soft_cfm = 0.0001f; newGlobalcontact.surface.soft_erp = 0.6f; // 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.001f); d.WorldSetAngularDamping(world, 0.001f); d.WorldSetAngularDampingThreshold(world, 0f); d.WorldSetLinearDampingThreshold(world, 0f); d.WorldSetMaxAngularSpeed(world, 256f); d.WorldSetCFM(world, 1e-6f); // a bit harder than default d.WorldSetERP(world, 0.6f); // higher than original d.WorldSetContactMaxCorrectingVel(world, 30.0f); // 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); if (staticPrimspace != null) return; //Reloading config, don't mess with this stuff d.HashSpaceSetLevels(space, HashspaceLow, HashspaceHigh); // spaces grid for static objects if (WorldExtents.X < WorldExtents.Y) // // constant is 1/log(2), -3 for division by 8 plus 0.5 for rounding GridSpaceScaleBits = (int) (Math.Log(WorldExtents.X)*1.4426950f - 2.5f); else GridSpaceScaleBits = (int) (Math.Log(WorldExtents.Y)*1.4426950f - 2.5f); if (GridSpaceScaleBits < 4) // no less than 16m side GridSpaceScaleBits = 4; else if (GridSpaceScaleBits > 10) GridSpaceScaleBits = 10; // no more than 1Km side int nspacesPerSideX2 = (int) (WorldExtents.X) >> GridSpaceScaleBits; int nspacesPerSideY2 = (int) (WorldExtents.Y) >> GridSpaceScaleBits; if ((int) (WorldExtents.X) > nspacesPerSideX2 << GridSpaceScaleBits) nspacesPerSideX2++; if ((int) (WorldExtents.Y) > nspacesPerSideY2 << GridSpaceScaleBits) nspacesPerSideY2++; staticPrimspace = new IntPtr[nspacesPerSideX2,nspacesPerSideY2]; IntPtr aSpace; for (int i = 0; i < nspacesPerSideX2; i++) { for (int j = 0; j < nspacesPerSideY2; j++) { aSpace = d.HashSpaceCreate(space); staticPrimspace[i, j] = aSpace; d.GeomSetCategoryBits(aSpace, (int) CollisionCategories.Space); waitForSpaceUnlock(aSpace); d.HashSpaceSetLevels(aSpace, -2, 8); d.SpaceSetSublevel(aSpace, 1); } } } }
public override void Dispose() { lock (OdeLock) { lock (_prims) { foreach (AuroraODEPrim prm in _prims) { RemovePrim(prm); } } //foreach (OdeCharacter act in _characters) //{ //RemoveAvatar(act); //} if (ContactgeomsArray != IntPtr.Zero) Marshal.FreeHGlobal(ContactgeomsArray); if (GlobalContactsArray != IntPtr.Zero) Marshal.FreeHGlobal(GlobalContactsArray); d.WorldDestroy(world); //d.CloseODE(); } m_rayCastManager.Dispose(); m_rayCastManager = null; }
public override void Dispose() { lock (OdeLock) { lock (_prims) { foreach (AuroraODEPrim prm in _prims) { RemovePrim(prm); } } //foreach (OdeCharacter act in _characters) //{ //RemoveAvatar(act); //} d.WorldDestroy(world); //d.CloseODE(); } m_rayCastManager.Dispose(); m_rayCastManager = null; }
public override void PostInitialise(IConfigSource config) { m_rayCastManager = new AuroraODERayCastRequestManager(this); RemoveQueue = new List<PhysicsActor>(); m_config = config; // Defaults if (Environment.OSVersion.Platform == PlatformID.Unix) { PID_D = 3200.0f; PID_P = 1400.0f; } else { PID_D = 2200.0f; PID_P = 900.0f; } if (m_config != null) { IConfig physicsconfig = m_config.Configs["AuroraODEPhysicsSettings"]; if (physicsconfig != null) { gravityx = physicsconfig.GetFloat("world_gravityx", 0f); gravityy = physicsconfig.GetFloat("world_gravityy", 0f); gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); m_avDecayTime = physicsconfig.GetFloat("avDecayTime", m_avDecayTime); m_avStopDecaying = physicsconfig.GetFloat("avStopDecaying", m_avStopDecaying); AllowUnderwaterPhysics = physicsconfig.GetBoolean("useUnderWaterPhysics", false); AllowAvGravity = physicsconfig.GetBoolean("useAvGravity", true); AvGravityHeight = physicsconfig.GetInt("avGravityHeight", 4096); AllowAvsToEscapeGravity = physicsconfig.GetBoolean("aviesCanEscapeGravity", true); m_AvFlySpeed = physicsconfig.GetFloat("AvFlySpeed", m_AvFlySpeed); m_allowJump = physicsconfig.GetBoolean("AllowJump", m_allowJump); m_usepreJump = physicsconfig.GetBoolean("UsePreJump", m_usepreJump); m_preJumpTime = physicsconfig.GetInt("PreJumpTime", m_preJumpTime); m_preJumpForceMultiplier = physicsconfig.GetFloat("PreJumpMultiplier", m_preJumpForceMultiplier); contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", 0.001f); 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("WalkSpeed", 1.3f) * 2); avMovementDivisorRun = (physicsconfig.GetFloat("RunSpeed", 0.8f) * 2); 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", 10); 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) { PID_D = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f); PID_P = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f); } else { PID_D = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); PID_P = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); } 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_useFlightCeilingHeight = physicsconfig.GetBoolean("Use_Flight_Ceiling_Height_Max", m_useFlightCeilingHeight); m_flightCeilingHeight = physicsconfig.GetFloat("Flight_Ceiling_Height_Max", m_flightCeilingHeight); //Rex minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 100000.01f); } } lock (OdeLock) { contacts = new d.ContactGeom[contactsPerCollision]; // 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; // 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; // 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); if (staticPrimspace != null) return;//Reloading config, don't mess with this stuff d.HashSpaceSetLevels (space, HashspaceLow, HashspaceHigh); // spaces grid for static objects if (WorldExtents.X < WorldExtents.Y) // // constant is 1/log(2), -3 for division by 8 plus 0.5 for rounding GridSpaceScaleBits = (int)(Math.Log ((double)WorldExtents.X) * 1.4426950f - 2.5f); else GridSpaceScaleBits = (int)(Math.Log ((double)WorldExtents.Y) * 1.4426950f - 2.5f); if (GridSpaceScaleBits < 4) // no less than 16m side GridSpaceScaleBits = 4; else if (GridSpaceScaleBits > 10) GridSpaceScaleBits = 10; // no more than 1Km side int nspacesPerSideX = (int)(WorldExtents.X) >> GridSpaceScaleBits; int nspacesPerSideY = (int)(WorldExtents.Y) >> GridSpaceScaleBits; if ((int)(WorldExtents.X) > nspacesPerSideX << GridSpaceScaleBits) nspacesPerSideX++; if ((int)(WorldExtents.Y) > nspacesPerSideY << GridSpaceScaleBits) nspacesPerSideY++; staticPrimspace = new IntPtr[nspacesPerSideX, nspacesPerSideY]; IntPtr aSpace; for (int i = 0; i < nspacesPerSideX; i++) { for (int j = 0; j < nspacesPerSideY; j++) { aSpace = d.HashSpaceCreate (IntPtr.Zero); staticPrimspace[i, j] = aSpace; d.GeomSetCategoryBits (aSpace, (int)CollisionCategories.Space); waitForSpaceUnlock (aSpace); d.SpaceSetSublevel (aSpace, 1); d.SpaceAdd (space, aSpace); } } } }
public override void PostInitialise(IConfigSource config) { m_rayCastManager = new AuroraODERayCastRequestManager(this); RemoveQueue = new List<PhysicsActor>(); m_config = config; // Defaults if (Environment.OSVersion.Platform == PlatformID.Unix) { PID_D = 3200.0f; PID_P = 1400.0f; avStandupTensor = 2000000f; } else { PID_D = 2200.0f; PID_P = 900.0f; avStandupTensor = 550000f; } if (m_config != null) { IConfig physicsconfig = m_config.Configs["AuroraODEPhysicsSettings"]; if (physicsconfig != null) { gravityx = physicsconfig.GetFloat("world_gravityx", 0f); gravityy = physicsconfig.GetFloat("world_gravityy", 0f); gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); m_avDecayTime = physicsconfig.GetFloat("avDecayTime", m_avDecayTime); m_avStopDecaying = physicsconfig.GetFloat("avStopDecaying", m_avStopDecaying); AllowUnderwaterPhysics = physicsconfig.GetBoolean("useUnderWaterPhysics", false); AllowAvGravity = physicsconfig.GetBoolean("useAvGravity", true); AvGravityHeight = physicsconfig.GetInt("avGravityHeight", 4096); AllowAvsToEscapeGravity = physicsconfig.GetBoolean("aviesCanEscapeGravity", true); UsePointGravity = physicsconfig.GetBoolean("usePointGravity", false); m_PointOfGravity.X = physicsconfig.GetFloat("point_gravityx", 0); m_PointOfGravity.Y = physicsconfig.GetFloat("point_gravityy", 0); m_PointOfGravity.Z = physicsconfig.GetFloat("point_gravityz", 0); 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) * 2); avMovementDivisorRun = (physicsconfig.GetFloat("av_movement_divisor_run", 0.8f) * 2); avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); 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) { PID_D = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f); PID_P = 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 { PID_D = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); PID_P = 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_useFlightCeilingHeight = physicsconfig.GetBoolean("Use_Flight_Ceiling_Height_Max", m_useFlightCeilingHeight); m_flightCeilingHeight = physicsconfig.GetFloat("Flight_Ceiling_Height_Max", m_flightCeilingHeight); //Rex 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]; // 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; // 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); d.HashSpaceSetLevels(space, HashspaceLow, HashspaceHigh); // spaces grid for static objects // get area in 8m multiples and in parts so it fits in integer and scales so 256m get similar sizes as previus GridSpaceScaleBits = (int)WorldExtents.X / 8; GridSpaceScaleBits *= (int)WorldExtents.Y / 8; // // constant is 1/log(2), plus 0.5 for rounding GridSpaceScaleBits = (int)(Math.Log((double)GridSpaceScaleBits) * 1.4426950f - 0.5f); GridSpaceScaleBits /= 2; // side take half as many bits if (GridSpaceScaleBits < 4) // no less than 16m side GridSpaceScaleBits = 4; else if (GridSpaceScaleBits > 8) GridSpaceScaleBits = 8; // no more than 256m side int nspacesPerSideX = (int)(WorldExtents.X) >> GridSpaceScaleBits; int nspacesPerSideY = (int)(WorldExtents.Y) >> GridSpaceScaleBits; staticPrimspace = new IntPtr[nspacesPerSideX, nspacesPerSideY]; IntPtr aSpace; for (int i = 0; i < nspacesPerSideX; i++) { for (int j = 0; j < nspacesPerSideY; j++) { aSpace = d.HashSpaceCreate(IntPtr.Zero); staticPrimspace[i, j] = aSpace; d.GeomSetCategoryBits(aSpace, (int)CollisionCategories.Space); waitForSpaceUnlock(aSpace); d.SpaceSetSublevel(aSpace, 1); d.SpaceAdd(space, aSpace); } } }