Example #1
0
        internal static PhysicsProperties DeserializeOrCreateNew(PhysxScene scene, IMaterial fallbackMaterial, byte[] serializedProperties)
        {
            PhysicsProperties properties = null;

            if (serializedProperties != null)
            {
                try
                {
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream(serializedProperties))
                    {
                        properties = ProtoBuf.Serializer.Deserialize <PhysicsProperties>(ms);
                    }

                    properties.FillMaterialFromDesc(scene.SceneImpl.Physics);

                    return(properties);
                }
                catch (Exception e)
                {
                    //unable to deserialize physics properties, fallthrough
                    m_log.ErrorFormat("[InWorldz.PhysxX] PhysicsProperties.DeserializeOrCreateNew: Deserialization failed, falling back to defaults: {0}", e);
                }
            }

            properties          = new PhysicsProperties();
            properties.Material = fallbackMaterial;

            return(properties);
        }
Example #2
0
        public PhysxPrim(PhysxPrim parent, PhysxScene 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 = (PhysicsProperties)properties;
            _collisionGroup = collisionGroup;

            this.AssignActor(myActor, myShape, _isPhysical, DeleteActorFlags.None);

            if (_properties.VehicleProps != null && _properties.VehicleProps.Type != VehicleType.None)
            {
                //init dynamics
                CheckCreateVehicleDynamics();
            }
        }
Example #3
0
        internal static PhysicsProperties DeserializeOrCreateNew(PhysxScene scene, IMaterial fallbackMaterial, byte[] serializedProperties)
        {
            PhysicsProperties properties = null;
            if (serializedProperties != null)
            {
                try
                {
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream(serializedProperties))
                    {
                        properties = ProtoBuf.Serializer.Deserialize<PhysicsProperties>(ms);
                    }

                    properties.FillMaterialFromDesc(scene.SceneImpl.Physics);

                    return properties;
                }
                catch (Exception e)
                {
                    //unable to deserialize physics properties, fallthrough
                    m_log.ErrorFormat("[InWorldz.PhysxX] PhysicsProperties.DeserializeOrCreateNew: Deserialization failed, falling back to defaults: {0}", e);
                }
            }

            properties = new PhysicsProperties();
            properties.Material = fallbackMaterial;

            return properties;
        }