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 override PhysicsActor AddPrimShape(string primName, AddPrimShapeFlags flags, BulkShapeData shapeData) { byte[] serializedPhysicsProperties = shapeData.PhysicsProperties; BasicPhysicsProperties properties = BasicPhysicsProperties.DeserializeOrCreateNew(this, shapeData.Material, serializedPhysicsProperties); bool isPhysical = (flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0; return new BasicPrim(this, shapeData.Pbs, shapeData.Position, shapeData.Rotation, /*Shape, Actor,*/ isPhysical, properties/*, collisionGroup*/); }
public override void BulkAddPrimShapes(ICollection<BulkShapeData> shapeData, AddPrimShapeFlags flags) { // Called on restore of objects when region boots up. Other times as well, but that's the critical. AddPrimShapeFlags _flags = flags; ICollection<BulkShapeData> _shapes = shapeData; int _totalNumShapes = _shapes.Count; bool _rootHasVdSet = false; bool isPhysical = (_flags & PhysicsScene.AddPrimShapeFlags.Physical) != 0; //we have all the shapes for the parent and all children, time to construct the group bool first = true; BasicPrim rootPrim = null; //CollisionGroupFlag collisionGroup = (_flags & PhysicsScene.AddPrimShapeFlags.Phantom) == 0 ? CollisionGroupFlag.Normal : CollisionGroupFlag.PhysicalPhantom; foreach (BulkShapeData shape in _shapes) { if (first) { BasicPhysicsProperties properties = BasicPhysicsProperties.DeserializeOrCreateNew(this, shape.Material, shape.PhysicsProperties); _rootHasVdSet = properties.VolumeDetectActive; if (_rootHasVdSet) { isPhysical = false; } rootPrim = new BasicPrim(this, shape.Pbs, shape.Position, shape.Rotation, /*_newPrimaryShape, actor, */ isPhysical, properties/*, collisionGroup*/); shape.OutActor = rootPrim; first = false; } else { BasicPhysicsProperties properties = BasicPhysicsProperties.DeserializeOrCreateNew(this, shape.Material, shape.PhysicsProperties); BasicPrim childPrim = new BasicPrim(rootPrim, this, shape.Pbs, shape.Position, shape.Rotation, /*phyShape, null,*/ isPhysical, properties/*, collisionGroup*/); rootPrim.LinkPrimAsChildSync(/*phyShape, */childPrim, shape.Position, shape.Rotation, true); shape.OutActor = childPrim; } } }
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; }