mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-12 11:11:42 +00:00
Merge branch 'bhkconstraint' into 'master'
Read bhkRagdollConstraint and bhkHingeConstraint See merge request OpenMW/openmw!3231
This commit is contained in:
commit
5bc06b3678
5 changed files with 266 additions and 0 deletions
|
@ -181,6 +181,8 @@ namespace Nif
|
||||||
{ "bhkListShape", &construct<bhkListShape, RC_bhkListShape> },
|
{ "bhkListShape", &construct<bhkListShape, RC_bhkListShape> },
|
||||||
{ "bhkRigidBody", &construct<bhkRigidBody, RC_bhkRigidBody> },
|
{ "bhkRigidBody", &construct<bhkRigidBody, RC_bhkRigidBody> },
|
||||||
{ "bhkRigidBodyT", &construct<bhkRigidBody, RC_bhkRigidBodyT> },
|
{ "bhkRigidBodyT", &construct<bhkRigidBody, RC_bhkRigidBodyT> },
|
||||||
|
{ "bhkRagdollConstraint", &construct<bhkRagdollConstraint, RC_bhkRagdollConstraint> },
|
||||||
|
{ "bhkHingeConstraint", &construct<bhkHingeConstraint, RC_bhkHingeConstraint> },
|
||||||
{ "BSLightingShaderProperty", &construct<BSLightingShaderProperty, RC_BSLightingShaderProperty> },
|
{ "BSLightingShaderProperty", &construct<BSLightingShaderProperty, RC_BSLightingShaderProperty> },
|
||||||
{ "BSEffectShaderProperty", &construct<BSEffectShaderProperty, RC_BSEffectShaderProperty> },
|
{ "BSEffectShaderProperty", &construct<BSEffectShaderProperty, RC_BSEffectShaderProperty> },
|
||||||
{ "NiSortAdjustNode", &construct<NiSortAdjustNode, RC_NiSortAdjustNode> },
|
{ "NiSortAdjustNode", &construct<NiSortAdjustNode, RC_NiSortAdjustNode> },
|
||||||
|
|
|
@ -187,6 +187,125 @@ namespace Nif
|
||||||
nif->skip(12); // Unused
|
nif->skip(12); // Unused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bhkConstraintCInfo::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
nif->get<unsigned int>(); // Number of entities, unused
|
||||||
|
mEntityA.read(nif);
|
||||||
|
mEntityB.read(nif);
|
||||||
|
|
||||||
|
mPriority = static_cast<ConstraintPriority>(nif->get<uint32_t>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkConstraintCInfo::post(Reader& nif)
|
||||||
|
{
|
||||||
|
mEntityA.post(nif);
|
||||||
|
mEntityB.post(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkPositionConstraintMotor::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
nif->read(mMinForce);
|
||||||
|
nif->read(mMaxForce);
|
||||||
|
nif->read(mTau);
|
||||||
|
nif->read(mDamping);
|
||||||
|
nif->read(mProportionalRecoveryVelocity);
|
||||||
|
nif->read(mConstantRecoveryVelocity);
|
||||||
|
mEnabled = nif->getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkVelocityConstraintMotor::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
nif->read(mMinForce);
|
||||||
|
nif->read(mMaxForce);
|
||||||
|
nif->read(mTau);
|
||||||
|
nif->read(mTargetVelocity);
|
||||||
|
mUseVelocityTarget = nif->getBoolean();
|
||||||
|
mEnabled = nif->getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkSpringDamperConstraintMotor::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
nif->read(mMinForce);
|
||||||
|
nif->read(mMaxForce);
|
||||||
|
nif->read(mSpringConstant);
|
||||||
|
nif->read(mSpringDamping);
|
||||||
|
mEnabled = nif->getBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkConstraintMotorCInfo::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
mType = static_cast<hkMotorType>(nif->get<uint32_t>());
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case hkMotorType::Motor_Position:
|
||||||
|
mPositionMotor.read(nif);
|
||||||
|
break;
|
||||||
|
case hkMotorType::Motor_Velocity:
|
||||||
|
mVelocityMotor.read(nif);
|
||||||
|
break;
|
||||||
|
case hkMotorType::Motor_SpringDamper:
|
||||||
|
mSpringDamperMotor.read(nif);
|
||||||
|
break;
|
||||||
|
case hkMotorType::Motor_None:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkRagdollConstraintCInfo::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
if (nif->getBethVersion() <= 16)
|
||||||
|
{
|
||||||
|
nif->read(mDataA.mPivot);
|
||||||
|
nif->read(mDataA.mPlane);
|
||||||
|
nif->read(mDataA.mTwist);
|
||||||
|
nif->read(mDataB.mPivot);
|
||||||
|
nif->read(mDataB.mPlane);
|
||||||
|
nif->read(mDataB.mTwist);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nif->read(mDataA.mTwist);
|
||||||
|
nif->read(mDataA.mPlane);
|
||||||
|
nif->read(mDataA.mMotor);
|
||||||
|
nif->read(mDataA.mPivot);
|
||||||
|
nif->read(mDataB.mTwist);
|
||||||
|
nif->read(mDataB.mPlane);
|
||||||
|
nif->read(mDataB.mMotor);
|
||||||
|
nif->read(mDataB.mPivot);
|
||||||
|
}
|
||||||
|
nif->read(mConeMaxAngle);
|
||||||
|
nif->read(mPlaneMinAngle);
|
||||||
|
nif->read(mPlaneMaxAngle);
|
||||||
|
nif->read(mTwistMinAngle);
|
||||||
|
nif->read(mTwistMaxAngle);
|
||||||
|
nif->read(mMaxFriction);
|
||||||
|
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() > 16)
|
||||||
|
mMotor.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkHingeConstraintCInfo::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
|
||||||
|
{
|
||||||
|
nif->read(mDataA.mPivot);
|
||||||
|
nif->read(mDataA.mPerpAxis1);
|
||||||
|
nif->read(mDataA.mPerpAxis2);
|
||||||
|
nif->read(mDataB.mPivot);
|
||||||
|
nif->read(mDataB.mAxis);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nif->read(mDataA.mAxis);
|
||||||
|
nif->read(mDataA.mPerpAxis1);
|
||||||
|
nif->read(mDataA.mPerpAxis2);
|
||||||
|
nif->read(mDataA.mPivot);
|
||||||
|
nif->read(mDataB.mAxis);
|
||||||
|
nif->read(mDataB.mPerpAxis1);
|
||||||
|
nif->read(mDataB.mPerpAxis2);
|
||||||
|
nif->read(mDataB.mPivot);
|
||||||
|
}
|
||||||
|
}
|
||||||
/// Record types
|
/// Record types
|
||||||
|
|
||||||
void bhkCollisionObject::read(NIFStream* nif)
|
void bhkCollisionObject::read(NIFStream* nif)
|
||||||
|
@ -448,4 +567,27 @@ namespace Nif
|
||||||
nif->readArray(mat);
|
nif->readArray(mat);
|
||||||
mTransform.set(mat.data());
|
mTransform.set(mat.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bhkConstraint::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
mInfo.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkConstraint::post(Reader& nif)
|
||||||
|
{
|
||||||
|
mInfo.post(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkRagdollConstraint::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
bhkConstraint::read(nif);
|
||||||
|
mConstraint.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bhkHingeConstraint::read(NIFStream* nif)
|
||||||
|
{
|
||||||
|
bhkConstraint::read(nif);
|
||||||
|
mConstraint.read(nif);
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
|
@ -210,6 +210,102 @@ namespace Nif
|
||||||
void read(NIFStream* nif);
|
void read(NIFStream* nif);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ConstraintPriority : uint32_t
|
||||||
|
{
|
||||||
|
Priority_Invalid = 0,
|
||||||
|
Priority_PhysicsTime = 1,
|
||||||
|
Priority_TimeOfImpact = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkConstraintCInfo
|
||||||
|
{
|
||||||
|
bhkEntityPtr mEntityA;
|
||||||
|
bhkEntityPtr mEntityB;
|
||||||
|
ConstraintPriority mPriority;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
void post(Reader& nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class hkMotorType : uint8_t
|
||||||
|
{
|
||||||
|
Motor_None = 0,
|
||||||
|
Motor_Position = 1,
|
||||||
|
Motor_Velocity = 2,
|
||||||
|
Motor_SpringDamper = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkPositionConstraintMotor
|
||||||
|
{
|
||||||
|
float mMinForce, mMaxForce;
|
||||||
|
float mTau;
|
||||||
|
float mDamping;
|
||||||
|
float mProportionalRecoveryVelocity;
|
||||||
|
float mConstantRecoveryVelocity;
|
||||||
|
bool mEnabled;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkVelocityConstraintMotor
|
||||||
|
{
|
||||||
|
float mMinForce, mMaxForce;
|
||||||
|
float mTau;
|
||||||
|
float mTargetVelocity;
|
||||||
|
bool mUseVelocityTarget;
|
||||||
|
bool mEnabled;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkSpringDamperConstraintMotor
|
||||||
|
{
|
||||||
|
float mMinForce, mMaxForce;
|
||||||
|
float mSpringConstant;
|
||||||
|
float mSpringDamping;
|
||||||
|
bool mEnabled;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkConstraintMotorCInfo
|
||||||
|
{
|
||||||
|
hkMotorType mType;
|
||||||
|
bhkPositionConstraintMotor mPositionMotor;
|
||||||
|
bhkVelocityConstraintMotor mVelocityMotor;
|
||||||
|
bhkSpringDamperConstraintMotor mSpringDamperMotor;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkRagdollConstraintCInfo
|
||||||
|
{
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
osg::Vec4f mPivot;
|
||||||
|
osg::Vec4f mPlane;
|
||||||
|
osg::Vec4f mTwist;
|
||||||
|
osg::Vec4f mMotor;
|
||||||
|
};
|
||||||
|
Data mDataA;
|
||||||
|
Data mDataB;
|
||||||
|
float mConeMaxAngle;
|
||||||
|
float mPlaneMinAngle, mPlaneMaxAngle;
|
||||||
|
float mTwistMinAngle, mTwistMaxAngle;
|
||||||
|
float mMaxFriction;
|
||||||
|
bhkConstraintMotorCInfo mMotor;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkHingeConstraintCInfo
|
||||||
|
{
|
||||||
|
struct HingeData
|
||||||
|
{
|
||||||
|
osg::Vec4f mPivot;
|
||||||
|
osg::Vec4f mAxis;
|
||||||
|
osg::Vec4f mPerpAxis1;
|
||||||
|
osg::Vec4f mPerpAxis2;
|
||||||
|
};
|
||||||
|
HingeData mDataA;
|
||||||
|
HingeData mDataB;
|
||||||
|
void read(NIFStream* nif);
|
||||||
|
};
|
||||||
|
|
||||||
/// Record types
|
/// Record types
|
||||||
|
|
||||||
// Abstract Bethesda Havok object
|
// Abstract Bethesda Havok object
|
||||||
|
@ -431,5 +527,26 @@ namespace Nif
|
||||||
osg::Matrixf mTransform;
|
osg::Matrixf mTransform;
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Abstract constraint
|
||||||
|
struct bhkConstraint : public bhkSerializable
|
||||||
|
{
|
||||||
|
bhkConstraintCInfo mInfo;
|
||||||
|
void read(NIFStream* nif) override;
|
||||||
|
void post(Reader& nif) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkRagdollConstraint : public bhkConstraint
|
||||||
|
{
|
||||||
|
bhkRagdollConstraintCInfo mConstraint;
|
||||||
|
void read(NIFStream* nif) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bhkHingeConstraint : public bhkConstraint
|
||||||
|
{
|
||||||
|
bhkHingeConstraintCInfo mConstraint;
|
||||||
|
void read(NIFStream* nif) override;
|
||||||
|
};
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -146,6 +146,8 @@ namespace Nif
|
||||||
RC_bhkListShape,
|
RC_bhkListShape,
|
||||||
RC_bhkRigidBody,
|
RC_bhkRigidBody,
|
||||||
RC_bhkRigidBodyT,
|
RC_bhkRigidBodyT,
|
||||||
|
RC_bhkRagdollConstraint,
|
||||||
|
RC_bhkHingeConstraint,
|
||||||
RC_BSLightingShaderProperty,
|
RC_BSLightingShaderProperty,
|
||||||
RC_BSEffectShaderProperty,
|
RC_BSEffectShaderProperty,
|
||||||
RC_NiClusterAccumulator,
|
RC_NiClusterAccumulator,
|
||||||
|
|
|
@ -137,6 +137,7 @@ namespace Nif
|
||||||
struct bhkWorldObject;
|
struct bhkWorldObject;
|
||||||
struct bhkShape;
|
struct bhkShape;
|
||||||
struct bhkSerializable;
|
struct bhkSerializable;
|
||||||
|
struct bhkEntity;
|
||||||
struct hkPackedNiTriStripsData;
|
struct hkPackedNiTriStripsData;
|
||||||
struct NiAccumulator;
|
struct NiAccumulator;
|
||||||
struct NiInterpolator;
|
struct NiInterpolator;
|
||||||
|
@ -175,6 +176,7 @@ namespace Nif
|
||||||
using NiCollisionObjectPtr = RecordPtrT<NiCollisionObject>;
|
using NiCollisionObjectPtr = RecordPtrT<NiCollisionObject>;
|
||||||
using bhkWorldObjectPtr = RecordPtrT<bhkWorldObject>;
|
using bhkWorldObjectPtr = RecordPtrT<bhkWorldObject>;
|
||||||
using bhkShapePtr = RecordPtrT<bhkShape>;
|
using bhkShapePtr = RecordPtrT<bhkShape>;
|
||||||
|
using bhkEntityPtr = RecordPtrT<bhkEntity>;
|
||||||
using hkPackedNiTriStripsDataPtr = RecordPtrT<hkPackedNiTriStripsData>;
|
using hkPackedNiTriStripsDataPtr = RecordPtrT<hkPackedNiTriStripsData>;
|
||||||
using NiAccumulatorPtr = RecordPtrT<NiAccumulator>;
|
using NiAccumulatorPtr = RecordPtrT<NiAccumulator>;
|
||||||
using NiInterpolatorPtr = RecordPtrT<NiInterpolator>;
|
using NiInterpolatorPtr = RecordPtrT<NiInterpolator>;
|
||||||
|
@ -194,6 +196,7 @@ namespace Nif
|
||||||
using NiTriStripsDataList = RecordListT<NiTriStripsData>;
|
using NiTriStripsDataList = RecordListT<NiTriStripsData>;
|
||||||
using bhkShapeList = RecordListT<bhkShape>;
|
using bhkShapeList = RecordListT<bhkShape>;
|
||||||
using bhkSerializableList = RecordListT<bhkSerializable>;
|
using bhkSerializableList = RecordListT<bhkSerializable>;
|
||||||
|
using bhkEntityList = RecordListT<bhkEntity>;
|
||||||
using NiControllerSequenceList = RecordListT<NiControllerSequence>;
|
using NiControllerSequenceList = RecordListT<NiControllerSequence>;
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
Loading…
Reference in a new issue