/// <summary> /// Creates a new type properties object for the currently configured constraint type, /// and sets the type properties object in the shape. /// </summary> void UpdateTypePropertyClass() { if (Selected && (_typeProperties != null)) { _typeProperties.DestroyHotspots(this); } switch (_constraintType) { case HavokConstraintType_e.BallAndSocket: _typeProperties = new BallAndSocketConstraintState(); break; case HavokConstraintType_e.Hinge: _typeProperties = new HingeConstraintState(); break; case HavokConstraintType_e.Ragdoll: _typeProperties = new RagdollConstraintState(); break; case HavokConstraintType_e.StiffSpring: _typeProperties = new StiffSpringConstraintState(); break; case HavokConstraintType_e.Fixed: _typeProperties = new FixedConstraintState(); break; case HavokConstraintType_e.Prismatic: _typeProperties = new PrismaticConstraintState(false); break; case HavokConstraintType_e.Cylindrical: _typeProperties = new PrismaticConstraintState(true); break; case HavokConstraintType_e.PointToPlane: _typeProperties = new PointToPlaneConstraintState(); break; case HavokConstraintType_e.PointToPath: _typeProperties = new PointToPathConstraintState(); break; case HavokConstraintType_e.Pulley: _typeProperties = new PulleyConstraintState(); break; } if (_typeProperties == null) { return; } if (_typeProperties.SupportsRotation()) { this.RemoveHint(HintFlags_e.NoRotation); } else { this.AddHint(HintFlags_e.NoRotation); } if (Selected && (_typeProperties != null)) { _typeProperties.CreateHotspots(this); } }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected HavokConstraintShape(SerializationInfo info, StreamingContext context) : base(info, context) { AddHint(HintFlags_e.NoScale); // Read dynamic constraint properties _constraintType = (HavokConstraintType_e)info.GetValue("_constraintType", typeof(HavokConstraintType_e)); _typeProperties = (ConstraintStateBase)info.GetValue("_typeProperties", typeof(ConstraintStateBase)); if ((_typeProperties != null) && _typeProperties.SupportsRotation()) { this.RemoveHint(HintFlags_e.NoRotation); } else { this.AddHint(HintFlags_e.NoRotation); } if (SerializationHelper.HasElement(info, "_objectKey")) { _objectKey = info.GetString("_objectKey"); } }
/// <summary> /// Creates a new type properties object for the currently configured constraint type, /// and sets the type properties object in the shape. /// </summary> void UpdateTypePropertyClass() { if (Selected && (_typeProperties != null)) _typeProperties.DestroyHotspots(this); switch (_constraintType) { case HavokConstraintType_e.BallAndSocket: _typeProperties = new BallAndSocketConstraintState(); break; case HavokConstraintType_e.Hinge: _typeProperties = new HingeConstraintState(); break; case HavokConstraintType_e.Ragdoll: _typeProperties = new RagdollConstraintState(); break; case HavokConstraintType_e.StiffSpring: _typeProperties = new StiffSpringConstraintState(); break; case HavokConstraintType_e.Fixed: _typeProperties = new FixedConstraintState(); break; case HavokConstraintType_e.Prismatic: _typeProperties = new PrismaticConstraintState(false); break; case HavokConstraintType_e.Cylindrical: _typeProperties = new PrismaticConstraintState(true); break; case HavokConstraintType_e.PointToPlane: _typeProperties = new PointToPlaneConstraintState(); break; case HavokConstraintType_e.PointToPath: _typeProperties = new PointToPathConstraintState(); break; case HavokConstraintType_e.Pulley: _typeProperties = new PulleyConstraintState(); break; } if (_typeProperties == null) return; if (_typeProperties.SupportsRotation()) this.RemoveHint(HintFlags_e.NoRotation); else this.AddHint(HintFlags_e.NoRotation); if (Selected && (_typeProperties != null)) _typeProperties.CreateHotspots(this); }
public override void OnDeserialization() { base.OnDeserialization(); // fixup broken saves (might have happend in early versions) switch (_constraintType) { case HavokConstraintType_e.BallAndSocket: if (!(_typeProperties is BallAndSocketConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.Hinge: if (!(_typeProperties is HingeConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.Ragdoll: if (!(_typeProperties is RagdollConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.StiffSpring: if (!(_typeProperties is StiffSpringConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.Fixed: if (!(_typeProperties is FixedConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.Prismatic: if (!(_typeProperties is PrismaticConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.Cylindrical: if (!(_typeProperties is PrismaticConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.PointToPlane: if (!(_typeProperties is PointToPlaneConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.PointToPath: if (!(_typeProperties is PointToPathConstraintState)) _typeProperties = null; break; case HavokConstraintType_e.Pulley: if (!(_typeProperties is PulleyConstraintState)) _typeProperties = null; break; } if (_typeProperties == null) UpdateTypePropertyClass(); }
/// <summary> /// Called when deserializing /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected HavokConstraintShape(SerializationInfo info, StreamingContext context) : base(info, context) { AddHint(HintFlags_e.NoScale); // Read dynamic constraint properties _constraintType = (HavokConstraintType_e)info.GetValue("_constraintType", typeof(HavokConstraintType_e)); _typeProperties = (ConstraintStateBase)info.GetValue("_typeProperties", typeof(ConstraintStateBase)); if ((_typeProperties != null) && _typeProperties.SupportsRotation()) this.RemoveHint(HintFlags_e.NoRotation); else this.AddHint(HintFlags_e.NoRotation); if (SerializationHelper.HasElement(info, "_objectKey")) _objectKey = info.GetString("_objectKey"); }
public override void OnDeserialization() { base.OnDeserialization(); // fixup broken saves (might have happend in early versions) switch (_constraintType) { case HavokConstraintType_e.BallAndSocket: if (!(_typeProperties is BallAndSocketConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.Hinge: if (!(_typeProperties is HingeConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.Ragdoll: if (!(_typeProperties is RagdollConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.StiffSpring: if (!(_typeProperties is StiffSpringConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.Fixed: if (!(_typeProperties is FixedConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.Prismatic: if (!(_typeProperties is PrismaticConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.Cylindrical: if (!(_typeProperties is PrismaticConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.PointToPlane: if (!(_typeProperties is PointToPlaneConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.PointToPath: if (!(_typeProperties is PointToPathConstraintState)) { _typeProperties = null; } break; case HavokConstraintType_e.Pulley: if (!(_typeProperties is PulleyConstraintState)) { _typeProperties = null; } break; } if (_typeProperties == null) { UpdateTypePropertyClass(); } }