public PhysicsScene GetScene(string sceneIdentifier) { //no lock needed, only called during an init PhysicsScene scene; if (!_scenes.TryGetValue(sceneIdentifier, out scene)) { scene = new BasicScene(); _scenes.Add(sceneIdentifier, scene); } return scene; }
public BasicActor(BasicScene scene, float height, float radius, OpenMetaverse.Vector3 position, OpenMetaverse.Quaternion rotation, bool flying, OpenMetaverse.Vector3 initialVelocity) { _scene = scene; _radius = Math.Max(radius, 0.2f); /* * The capsule is defined as a position, a vertical height, and a radius. The height is the distance between the * two sphere centers at the end of the capsule. In other words: * * p = pos (returned by controller) * h = height * r = radius * * p = center of capsule * top sphere center = p.z + h*0.5 * bottom sphere center = p.z - h*0.5 * top capsule point = p.z + h*0.5 + r * bottom capsule point = p.z - h*0.5 - r */ _height = height; _flying = flying; float volume = (float)(Math.PI * Math.Pow(_radius, 2) * this.CapsuleHeight); _mass = CHARACTER_DENSITY * volume; _position = position; _rotation = rotation; DoZDepenetration(); _lastSync = (uint)Environment.TickCount; _vTarget = initialVelocity; _velocity = initialVelocity; if (_vTarget != OpenMetaverse.Vector3.Zero) { //hack to continue at velocity until the controller picks up _lastVelocityNonZero = OpenSim.Framework.Util.GetLongTickCount() - VELOCITY_RAMPUP_TIME; } }
internal static BasicPhysicsProperties DeserializeOrCreateNew(BasicScene scene, IMaterial fallbackMaterial, byte[] serializedProperties) { BasicPhysicsProperties properties = null; if (serializedProperties != null) { try { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(serializedProperties)) { properties = ProtoBuf.Serializer.Deserialize<BasicPhysicsProperties>(ms); } return properties; } catch (Exception e) { //unable to deserialize physics properties, fallthrough m_log.ErrorFormat("[BasicPhysics] BasicPhysicsProperties.DeserializeOrCreateNew: Deserialization failed, falling back to defaults: {0}", e); } } properties = new BasicPhysicsProperties(); properties.Material = fallbackMaterial; return properties; }
public BasicPrim(BasicPrim parent, BasicScene scene, PrimitiveBaseShape baseShape, OpenMetaverse.Vector3 pos, OpenMetaverse.Quaternion rotation, /*PhysicsShape myShape, PhysX.RigidActor myActor,*/ bool isPhysical, IPhysicsProperties properties/*, CollisionGroupFlag collisionGroup*/) { _parentPrim = parent; _scene = scene; _pbs = baseShape; _position = pos; _rotation = rotation; _isPhysical = isPhysical; _properties = (BasicPhysicsProperties)properties; //_collisionGroup = collisionGroup; _acceleration = OpenMetaverse.Vector3.Zero; _mass = OBJECT_DENSITY * _pbs.Scale.X * _pbs.Scale.Y * _pbs.Scale.Z; //this.AssignActor(myActor, myShape, _isPhysical, DeleteActorFlags.None); }
public BasicPrim(BasicScene scene, PrimitiveBaseShape baseShape, OpenMetaverse.Vector3 pos, OpenMetaverse.Quaternion rotation, /*PhysicsShape myShape, PhysX.RigidActor myActor,*/ bool isPhysical, IPhysicsProperties properties/*, CollisionGroupFlag collisionGroup*/) : this(null, scene, baseShape, pos, rotation, /*myShape, myActor,*/ isPhysical, properties/*, collisionGroup*/) { }