diff --git a/include/NIF_IO.h b/include/NIF_IO.h index 5f3e31bf447e4c46bdf72ba124f06b0c7e2d82ff..cf557a2c2b80f152324abf2816c5de2b02669a0d 100644 --- a/include/NIF_IO.h +++ b/include/NIF_IO.h @@ -144,6 +144,10 @@ void NifStream( Triangle const & val, ostream& out, const NifInfo & info); void NifStream( Vector3 & val, istream& in, const NifInfo & info); void NifStream( Vector3 const & val, ostream& out, const NifInfo & info ); +//Vector4 +void NifStream( Vector4 & val, istream& in, const NifInfo & info); +void NifStream( Vector4 const & val, ostream& out, const NifInfo & info ); + //Float2 void NifStream( Float2 & val, istream& in, const NifInfo & info); void NifStream( Float2 const & val, ostream& out, const NifInfo & info ); diff --git a/include/gen/LimitedHingeDescriptor.h b/include/gen/LimitedHingeDescriptor.h index dbbd8b79e19ab2efe77ca9826fcebbda6fee3491..cfd98f73d22d2b742276b982b2732cb0bf88fe0a 100644 --- a/include/gen/LimitedHingeDescriptor.h +++ b/include/gen/LimitedHingeDescriptor.h @@ -24,23 +24,23 @@ struct LimitedHingeDescriptor { /*! Copy Operator */ NIFLIB_API LimitedHingeDescriptor & operator=( const LimitedHingeDescriptor & src ); /*! Pivot point around which the object will rotate. */ - Float4 pivotA; + Vector4 pivotA; /*! Axis of rotation. */ - Float4 axleA; + Vector4 axleA; /*! Vector in the rotation plane which defines the zero angle. */ - Float4 perp2axleina1; + Vector4 perp2axleina1; /*! * Vector in the rotation plane, orthogonal on the previous one, which defines the * positive direction of rotation. This is always the vector product of Axle A and * Perp2 Axle In A1. */ - Float4 perp2axleina2; + Vector4 perp2axleina2; /*! Pivot A in second entity coordinate system. */ - Float4 pivotB; + Vector4 pivotB; /*! Axle A in second entity coordinate system. */ - Float4 axleB; + Vector4 axleB; /*! Perp2 Axle In A2 in second entity coordinate system. */ - Float4 perp2axleinb2; + Vector4 perp2axleinb2; /*! Minimum rotation angle. */ float minAngle; /*! Maximum rotation angle. */ diff --git a/include/gen/RagdollDescriptor.h b/include/gen/RagdollDescriptor.h index ce510faec0842c227642e7d25333f64144e50af0..3a691ed54ff1b40c6c74393676d8b57f2a0a079e 100644 --- a/include/gen/RagdollDescriptor.h +++ b/include/gen/RagdollDescriptor.h @@ -27,23 +27,23 @@ struct RagdollDescriptor { /*! Copy Operator */ NIFLIB_API RagdollDescriptor & operator=( const RagdollDescriptor & src ); /*! Point around which the object will rotate. */ - Float4 pivotA; + Vector4 pivotA; /*! * Defines the orthogonal directions in which the shape can be controlled (namely * in this direction, and in the direction orthogonal on this one and Twist A). */ - Float4 planeA; + Vector4 planeA; /*! * Central directed axis of the cone in which the object can rotate. Orthogonal on * Plane A. */ - Float4 twistA; + Vector4 twistA; /*! Pivot A in second entity coordinate system. */ - Float4 pivotB; + Vector4 pivotB; /*! Plane A in second entity coordinate system. */ - Float4 planeB; + Vector4 planeB; /*! Twist A in second entity coordinate system. */ - Float4 twistB; + Vector4 twistB; /*! * Maximum angle the object can rotate around the vector orthogonal on Plane A and * Twist A relative to the Twist A vector. Note that Cone Min Angle is not stored, diff --git a/include/gen/enums.h b/include/gen/enums.h index 778ea1736a4fce5332cffb133ef7affc57815282..e539bdbd618b230529e47778b96357c31fbebce5 100644 --- a/include/gen/enums.h +++ b/include/gen/enums.h @@ -31,6 +31,23 @@ enum CollisionMode { ostream & operator<<( ostream & out, CollisionMode const & val ); +enum DeactivatorType { + DEACTIVATOR_INVALID = 0, /*!< Invalid */ + DEACTIVATOR_NEVER = 1, /*!< This will force the rigid body to never deactivate. */ + DEACTIVATOR_SPATIAL = 2, /*!< Tells Havok to use a spatial deactivation scheme. This makes use of high and low frequencies of positional motion to determine when deactivation should occur. */ +}; + +ostream & operator<<( ostream & out, DeactivatorType const & val ); + +enum hkResponseType { + RESPONSE_INVALID = 0, /*!< Invalid Response */ + RESPONSE_SIMPLE_CONTACT = 1, /*!< Do normal collision resolution */ + RESPONSE_REPORTING = 2, /*!< No collision resolution is performed but listeners are called */ + RESPONSE_NONE = 3, /*!< Do nothing, ignore all the results. */ +}; + +ostream & operator<<( ostream & out, hkResponseType const & val ); + /*! Determines how a NiTextureTransformController animates the UV coordinates. */ enum TexTransform { TT_TRANSLATE_U = 0, /*!< Means this controller moves the U texture cooridnates. */ @@ -231,6 +248,25 @@ enum OblivionLayer { ostream & operator<<( ostream & out, OblivionLayer const & val ); +/*! + * A list of possible solver deactivation settings. This value defines how the + * solver deactivates objects. The solver works on a per object + * basis. + * Note: Solver deactivation does not save CPU, but reduces + * creeping of + * movable objects in a pile quite dramatically. + */ +enum SolverDeactivation { + SOLVER_DEACTIVATION_INVALID = 0, /*!< Invalid */ + SOLVER_DEACTIVATION_OFF = 1, /*!< No solver deactivation */ + SOLVER_DEACTIVATION_LOW = 2, /*!< Very conservative deactivation, typically no visible artifacts. */ + SOLVER_DEACTIVATION_MEDIUM = 3, /*!< Normal deactivation, no serious visible artifacts in most cases */ + SOLVER_DEACTIVATION_HIGH = 4, /*!< Fast deactivation, visible artifacts */ + SOLVER_DEACTIVATION_MAX = 5, /*!< Very fast deactivation, visible artifacts */ +}; + +ostream & operator<<( ostream & out, SolverDeactivation const & val ); + /*! This enum lists the different face culling options. */ enum FaceDrawMode { DRAW_CCW_OR_BOTH = 0, /*!< use application defaults? */ @@ -327,24 +363,18 @@ ostream & operator<<( ostream & out, ApplyMode const & val ); /*! * The motion system. 4 (Box) is used for everything movable. 7 (Keyframed) is used * on statics and animated stuff. - * - * Oblivion's ssg commando reveals even more values: - * 0: Keyframed - * 1: Box - * 2: Sphere - * 3: Sphere - * 4: Box - * 5: Box - * 6: Keyframed - * 7: Keyframed - * 8: Box - * 9+: Keyframed? */ enum MotionSystem { - MO_SYS_SPHERE = 2, /*!< Sphere */ - MO_SYS_BOX = 4, /*!< Box */ - MO_SYS_KEYFRAMED_BIPED = 6, /*!< Keyframed (used for creatures) */ - MO_SYS_KEYFRAMED = 7, /*!< Keyframed (used for weapons) */ + MO_SYS_INVALID = 0, /*!< Invalid */ + MO_SYS_DYNAMIC = 1, /*!< A fully-simulated, movable rigid body. At construction time the engine checks the input inertia and selects MO_SYS_SPHERE_INERTIA or MO_SYS_BOX_INERTIA as appropriate. */ + MO_SYS_SPHERE = 2, /*!< Simulation is performed using a sphere inertia tensor. */ + MO_SYS_SPHERE_INERTIA = 3, /*!< This is the same as MO_SYS_SPHERE_INERTIA, except that simulation of the rigid body is "softened". */ + MO_SYS_BOX = 4, /*!< Simulation is performed using a box inertia tensor. */ + MO_SYS_BOX_STABILIZED = 5, /*!< This is the same as MO_SYS_BOX_INERTIA, except that simulation of the rigid body is "softened". */ + MO_SYS_KEYFRAMED = 6, /*!< Simulation is not performed as a normal rigid body. The keyframed rigid body has an infinite mass when viewed by the rest of the system. (used for creatures) */ + MO_SYS_FIXED = 7, /*!< This motion type is used for the static elements of a game scene, e.g. the landscape. Faster than MO_SYS_KEYFRAMED at velocity 0. (used for weapons) */ + MO_SYS_THIN_BOX = 8, /*!< A box inertia motion which is optimized for thin boxes and has less stability problems */ + MO_SYS_CHARACTER = 9, /*!< A specialized motion used for character controllers */ }; ostream & operator<<( ostream & out, MotionSystem const & val ); @@ -435,15 +465,16 @@ ostream & operator<<( ostream & out, TexClampMode const & val ); /*! The motion type. Determines quality of motion? */ enum MotionQuality { - MO_QUAL_MOVING = 0, /*!< Moving */ - MO_QUAL_FIXED = 1, /*!< Fixed */ - MO_QUAL_KEYFRAMED = 2, /*!< Keyframed */ - MO_QUAL_MOVING2 = 3, /*!< Moving(?) */ - MO_QUAL_MOVING3 = 4, /*!< Moving(?) */ - MO_QUAL_CRITICAL = 5, /*!< Critical */ - MO_QUAL_BULLET = 6, /*!< Bullet */ - MO_QUAL_USER = 7, /*!< User */ - MO_QUAL_NULL = 8, /*!< Null */ + MO_QUAL_INVALID = 0, /*!< Automatically assigned to MO_QUAL_FIXED, MO_QUAL_KEYFRAMED or MO_QUAL_DEBRIS */ + MO_QUAL_FIXED = 1, /*!< Use this for fixed bodies. */ + MO_QUAL_KEYFRAMED = 2, /*!< Use this for moving objects with infinite mass. */ + MO_QUAL_DEBRIS = 3, /*!< Use this for all your debris objects */ + MO_QUAL_MOVING = 4, /*!< Use this for moving bodies, which should not leave the world. */ + MO_QUAL_CRITICAL = 5, /*!< Use this for all objects, which you cannot afford to tunnel through the world at all */ + MO_QUAL_BULLET = 6, /*!< Use this for very fast objects */ + MO_QUAL_USER = 7, /*!< For user. */ + MO_QUAL_CHARACTER = 8, /*!< Use this for rigid body character controllers */ + MO_QUAL_KEYFRAMED_REPORT = 9, /*!< Use this for moving objects with infinite mass which should report contact points and Toi-collisions against all other bodies, including other fixed and keyframed bodies. */ }; ostream & operator<<( ostream & out, MotionQuality const & val ); diff --git a/include/gen/enums_intl.h b/include/gen/enums_intl.h index 86f1cd9a3bc6f4f6ada421f1f05e5491e7b4cc7e..b225b1341492003fe0ec4c4beb24d55c7a7a2bbe 100644 --- a/include/gen/enums_intl.h +++ b/include/gen/enums_intl.h @@ -24,6 +24,12 @@ void NifStream( ForceType const & val, ostream& out, const NifInfo & info = NifI void NifStream( CollisionMode & val, istream& in, const NifInfo & info = NifInfo() ); void NifStream( CollisionMode const & val, ostream& out, const NifInfo & info = NifInfo() ); +void NifStream( DeactivatorType & val, istream& in, const NifInfo & info = NifInfo() ); +void NifStream( DeactivatorType const & val, ostream& out, const NifInfo & info = NifInfo() ); + +void NifStream( hkResponseType & val, istream& in, const NifInfo & info = NifInfo() ); +void NifStream( hkResponseType const & val, ostream& out, const NifInfo & info = NifInfo() ); + //---TexTransform---// @@ -85,6 +91,12 @@ void NifStream( OblivionLayer & val, istream& in, const NifInfo & info = NifInfo void NifStream( OblivionLayer const & val, ostream& out, const NifInfo & info = NifInfo() ); +//---SolverDeactivation---// + +void NifStream( SolverDeactivation & val, istream& in, const NifInfo & info = NifInfo() ); +void NifStream( SolverDeactivation const & val, ostream& out, const NifInfo & info = NifInfo() ); + + //---FaceDrawMode---// void NifStream( FaceDrawMode & val, istream& in, const NifInfo & info = NifInfo() ); diff --git a/include/nif_basic_types.h b/include/nif_basic_types.h index fb8af131781f591bcd66cba825c0054fd61cecbd..07a7c10176ed8d858e1bb224c6007209977a2a87 100644 --- a/include/nif_basic_types.h +++ b/include/nif_basic_types.h @@ -5,6 +5,7 @@ All rights reserved. Please see niflib.h for license. */ #define _NIF_BASIC_TYPES_H_ #include <string> +#include <stdarg.h> #include "gen/enums.h" #include "nif_versions.h" @@ -79,9 +80,16 @@ struct NifInfo { template<int size, class T> struct array { array() { - for ( size_t i = 0; i < size; ++i ) { + for ( size_t i = 0; i < size; ++i ) + data[i] = T(); + } + array(size_t n, ...) { + va_list argptr; + va_start(argptr, n); + for ( size_t i = 0; i < n && i < size; ++i ) + data[i] = va_arg( argptr, T ); + for ( size_t i = n; i < size; ++i ) data[i] = T(); - } } ~array() {} T & operator[]( unsigned int index ) { diff --git a/include/nif_math.h b/include/nif_math.h index de6c64176100adbb1b3a7aa54c37ab13ac24759a..3dd3bf8365be08f4e733dad677a77859c1220a74 100644 --- a/include/nif_math.h +++ b/include/nif_math.h @@ -20,6 +20,7 @@ namespace Niflib { struct TexCoord; struct Triangle; struct Vector3; +struct Vector4; struct Color3; struct Color4; struct Quaternion; @@ -156,7 +157,7 @@ struct Vector3 { */ NIFLIB_API float Magnitude() const; - /* This function returns a normalization of this vector. A vecctor pointing in the same + /* This function returns a normalization of this vector. A vector pointing in the same * direction but with a magnitude, or length, of 1. */ NIFLIB_API Vector3 Normalized() const; @@ -256,6 +257,153 @@ struct Vector3 { //Vector3 & operator*=( const Matrix44 & rh ); }; +/*!Represents a position or direction in 3D space*/ +struct Vector4 { + float x; /*!< The X component of this vector. */ + float y; /*!< The Y component of this vector. */ + float z; /*!< The Z component of this vector. */ + float w; /*!< The W component of this vector. */ + + /*!Default constructor.*/ + NIFLIB_API Vector4() { x = y = z = w = 0.0f; } + + /*! This constructor can be used to set all values in this structure during initialization + * \param[in] x The value to set X to. + * \param[in] y The value to set Y to. + * \param[in] z The value to set Z to. + * \param[in] w The value to set W to. + */ + NIFLIB_API Vector4(float x, float y, float z, float w = 0.0f) { + this->x = x; + this->y = y; + this->z = z; + this->w = w; + } + + /*! This constructor can be used to initialize this Vector4 with another Vector4 + * \param[in] v The Vector4 to construct this one from + */ + NIFLIB_API Vector4( const Vector4 & v) { x = v.x; y = v.y; z = v.z; w = v.w;} + + /*! This constructor can be used to initialize this Vector4 with a Vector3 + * \param[in] v The Vector3 to construct this one from + */ + NIFLIB_API Vector4( const Vector3 & v) { x = v.x; y = v.y; z = v.z; w = 0.0f;} + + /*! This constructor can be used to initialize this Vector4 with a Float4 + * \param[in] v The Float4 to construct this one from + */ + NIFLIB_API Vector4( const Float4 & v); + + /*! Destructor */ + NIFLIB_API ~Vector4() {} + + /*! This function can be used to set all values in the structure at the same time. + * \param[in] x The value to set X to. + * \param[in] y The value to set Y to. + * \param[in] z The value to set Z to. + * \param[in] w The value to set W to. + */ + NIFLIB_API void Set(float x, float y, float z, float w = 0.0f) { + this->x = x; + this->y = y; + this->z = z; + this->w = w; + } + + /* This function calculates the magnitude of this vector + * \return the magnitude of the vector; its length. + */ + NIFLIB_API float Magnitude() const; + + /* This function returns a normalization of this vector. A vector pointing in the same + * direction but with a magnitude, or length, of 1. + */ + NIFLIB_API Vector4 Normalized() const; + + /* Allows the addition of vectors. Each component, x, y, z, w is added with + * the same component of the other vector. + * \return The result of the addition. + */ + NIFLIB_API Vector4 operator+( const Vector4 & rh ) const; + + /* Adds the two vectors and then sets the result to the left-hand vector. + * \return This vector is returned. + */ + NIFLIB_API Vector4 & operator+=( const Vector4 & rh ); + + /* Allows the subtraction of vectors. Each component, x, y, y, is subtracted from + * the same component of the other vector. + * \return The result of the subtraction. + */ + NIFLIB_API Vector4 operator-( const Vector4 & rh ) const; + + /* This operator subtracts the two vectors and then sets the result to the left-hand vector. + * \return This vector is returned. + */ + NIFLIB_API Vector4 & operator-=( const Vector4 & rh); + + /* Allows scaler multiplication, that is multiplying all components of the + * vector, x, y and z, by the same number. + * \return The result of the multiplication. + */ + NIFLIB_API Vector4 operator*( const float & rh) const; //Scalar Multiply + + /* Multiplies a vector by a scalar and then sets the result to the left-hand vector. + * \return This vector is returned. + */ + Vector4 & operator*=( const float & rh ); + + /* Multiplies a vector by a vector using the dot product + * \return The dot product of the two vectors. + */ + NIFLIB_API float operator*( const Vector4 & v ) const; + + /* Multiplies a vector by a vector using the cross product + * \return The cross product of the two vectors. + */ + NIFLIB_API Vector4 operator^( const Vector4 & v ) const; + + /* Allows scaler division, that is dividing all components of the + * vector, x, y and z, by the same number. + * \return The result of the division. + */ + NIFLIB_API Vector4 operator/( const float & rh ) const; + + /* Divides a vector by a scalar and then sets the result to the left-hand vector. + * \return This vector is returned. + */ + Vector4 & operator/=( const float & rh ); + + /* Sets the components of this Vector4 to those of another Vector4 + * \return This vector is returned. + */ + NIFLIB_API Vector4 & operator=( const Vector4 & v ) { x = v.x; y = v.y; z = v.z; w = v.w; return *this; } + + /* Tests the equality of two Vector4 structures. Vectors are considered equal if all + * three components are equal. + */ + NIFLIB_API bool operator==( const Vector4 & rh ) const; + + /* Tests the inequality of two Vector4 structures. Vectors are considered equal if all + * three components are equal. + */ + NIFLIB_API bool operator!=( const Vector4 & rh ) const; + + /*! The bracket operator makes it possible to use this structure like a C++ array. + * \param[in] n The index into the data array. Should be 0, 1, 2, or 3. + * \return The value at the given array index by reference so it can be read or set via the bracket operator. + */ + NIFLIB_API float & operator[](int n); + + /*! The bracket operator makes it possible to use this structure like a C++ array. + * \param[in] n The index into the data array. Should be 0, 1, 2, or 3. + * \return The value at the given array index by reference so it can be read or set via the bracket operator. + */ + NIFLIB_API float operator[](int n) const; + +}; + /* Stores two floating point numbers. Used as a row of a Matrix22 */ struct Float2 { float data[2]; /*!< The two floating point numbers stored as an array. */ @@ -514,6 +662,11 @@ struct Float4 { data[4] = f4; } + /*! This constructor can be used to initialize this Float4 with a Vector4 + * \param[in] v The Vector4 to construct this one from + */ + NIFLIB_API Float4( const Vector4 & v) { Set(v.x, v.y, v.z, v.w); } + /*! This function can be used to set all values in the structure at the same time. * \param[in] f1 The value to set the first floating point number to. * \param[in] f2 The value to set the second floating point number to. diff --git a/include/obj/BSXFlags.h b/include/obj/BSXFlags.h index 5f5c9ea13aa691ef5ac7bfd645b7608b33644ec5..1ff87eec641003cf9365b57a224766b010a75857 100644 --- a/include/obj/BSXFlags.h +++ b/include/obj/BSXFlags.h @@ -23,10 +23,10 @@ typedef Ref<BSXFlags> BSXFlagsRef; * Controls animation and collision. Integer holds flags: * Bit 0 : enable animation * Bit 1 : enable collision - * Bit 2 : unknown, usually zero + * Bit 2 : is skeleton nif? * Bit 3 : toggable? unknown, set to 1 on oblivion signs - * Bit 4 : unknown, usually zero - * Bit 5 : trigger? + * Bit 4 : FlameNodes present + * Bit 5 : EditorMarkers present */ class BSXFlags : public NiIntegerExtraData { public: diff --git a/include/obj/NiBinaryVoxelData.h b/include/obj/NiBinaryVoxelData.h index b7929cb6e55ac7326380a11835ab0fbb0af9950c..dba2118fbb75e71aa866fd6c34a34d373f33f302 100644 --- a/include/obj/NiBinaryVoxelData.h +++ b/include/obj/NiBinaryVoxelData.h @@ -68,7 +68,7 @@ protected: /*! Unknown. */ mutable unsigned int numUnknownVectors; /*! Vectors on the unit sphere. */ - vector<Float4 > unknownVectors; + vector<Vector4 > unknownVectors; /*! Unknown. */ mutable unsigned int numUnknownBytes2; /*! Unknown. */ diff --git a/include/obj/bhkConvexVerticesShape.h b/include/obj/bhkConvexVerticesShape.h index fe4dadd7e205d6396022f955206ba81aab94281f..24b7a1fc7af623a74ab44fbf371a765d2d09a38b 100644 --- a/include/obj/bhkConvexVerticesShape.h +++ b/include/obj/bhkConvexVerticesShape.h @@ -104,12 +104,12 @@ public: * Used to retrieve the normal and the distance to center for vertices. The size of the vector will either be zero if no normals are used, or be the same as the vertex count retrieved with the IShapeData::GetVertexCount function. * \return A vector containing the normals used by this mesh, if any. */ - NIFLIB_API vector<Float4> GetNormalsAndDist() const; + NIFLIB_API vector<Vector4> GetNormalsAndDist() const; /*! * Used to set the normal and the distance to center for vertices. The size of the vector will either be zero if no normals are used, or be the same as the vertex count retrieved with the IShapeData::GetVertexCount function. */ - NIFLIB_API void SetNormalsAndDist(const vector<Float4>& value); + NIFLIB_API void SetNormalsAndDist(const vector<Vector4>& value); //--END CUSTOM CODE--// protected: @@ -121,7 +121,7 @@ protected: /*! Number of vertices. */ mutable unsigned int numVertices; /*! Vertices. Fourth component is 0. Lexicographically sorted. */ - vector<Float4 > vertices; + vector<Vector4 > vertices; /*! The number of half spaces. */ mutable unsigned int numNormals; /*! @@ -131,7 +131,7 @@ protected: * and n, where v is any vertex on the separating plane, and n is the normal. * Lexicographically sorted. */ - vector<Float4 > normals; + vector<Vector4 > normals; public: /*! NIFLIB_HIDDEN function. For internal use only. */ NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); diff --git a/include/obj/bhkHingeConstraint.h b/include/obj/bhkHingeConstraint.h index ae01bd39037f35f829a94833d481eecaf8a3258d..7965f7190efa648ffa78f30346e0598f12d2c219 100644 --- a/include/obj/bhkHingeConstraint.h +++ b/include/obj/bhkHingeConstraint.h @@ -56,15 +56,15 @@ public: //--END CUSTOM CODE--// protected: /*! Pivot A. */ - Float4 pivotA; + Vector4 pivotA; /*! Unknown. */ - Float4 perp2axleina1; + Vector4 perp2axleina1; /*! Unknown. */ - Float4 perp2axleina2; + Vector4 perp2axleina2; /*! Pivot B. */ - Float4 pivotB; + Vector4 pivotB; /*! Unknown. */ - Float4 axleB; + Vector4 axleB; public: /*! NIFLIB_HIDDEN function. For internal use only. */ NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); diff --git a/include/obj/bhkPrismaticConstraint.h b/include/obj/bhkPrismaticConstraint.h index 4860657370537472511ddfc112d4920a08ffc63f..99d5d470085251b49dbbe450b96020ab2273ce55 100644 --- a/include/obj/bhkPrismaticConstraint.h +++ b/include/obj/bhkPrismaticConstraint.h @@ -56,15 +56,15 @@ public: //--END CUSTOM CODE--// protected: /*! Pivot A. */ - Float4 pivotA; + Vector4 pivotA; /*! 4x4 rotation matrix, rotates the child entity. */ - array<4,Float4 > rotation; + array<4,Vector4 > rotation; /*! Pivot B. */ - Float4 pivotB; + Vector4 pivotB; /*! Describes the axis the object is able to travel along. Unit vector. */ - Float4 slidingAxis; + Vector4 slidingAxis; /*! Plane normal. Describes the plane the object is able to move on. */ - Float4 plane; + Vector4 plane; /*! Describe the min distance the object is able to travel. */ float minDistance; /*! Describe the max distance the object is able to travel. */ diff --git a/include/obj/bhkRigidBody.h b/include/obj/bhkRigidBody.h index a1d93d5edad1393740ff61231572da6b96d1c60d..a5ae39fe89512a7659ff2a1ee6c847acf8fab286 100644 --- a/include/obj/bhkRigidBody.h +++ b/include/obj/bhkRigidBody.h @@ -85,13 +85,13 @@ public: * Gets the current translation of this rigid body. * \return The translation of this rigid body. */ - NIFLIB_API Vector3 GetTranslation() const; + NIFLIB_API Vector4 GetTranslation() const; /*! * Sets a new translation for this rigid body. * \param[in] value The new translation for this rigid body. */ - NIFLIB_API void SetTranslation( const Vector3 & value ); + NIFLIB_API void SetTranslation( const Vector4 & value ); /*! * Gets the current rotation of this rigid body. @@ -109,25 +109,25 @@ public: * Gets the current linear velocity of this rigid body. * \return The linear velocity of this rigid body. */ - NIFLIB_API Vector3 GetLinearVelocity() const; + NIFLIB_API Vector4 GetLinearVelocity() const; /*! * Sets a new linear velocity for this rigid body. * \param[in] value The new linear velocity for this rigid body. */ - NIFLIB_API void SetLinearVelocity( const Vector3 & value ); + NIFLIB_API void SetLinearVelocity( const Vector4 & value ); /*! * Gets the current angular velocity of this rigid body. * \return The angular velocity of this rigid body. */ - NIFLIB_API Vector3 GetAngularVelocity() const; + NIFLIB_API Vector4 GetAngularVelocity() const; /*! * Sets a new angular velocity for this rigid body. * \param[in] value The new angular velocity for this rigid body. */ - NIFLIB_API void SetAngularVelocity( const Vector3 & value ); + NIFLIB_API void SetAngularVelocity( const Vector4 & value ); /*! * Gets the current inertia of this rigid body. @@ -145,13 +145,13 @@ public: * Gets the current center point of this rigid body. * \return The center point of this rigid body. */ - NIFLIB_API Vector3 GetCenter() const; + NIFLIB_API Vector4 GetCenter() const; /*! * Sets a new center point for this rigid body. * \param[in] value The new center point for this rigid body. */ - NIFLIB_API void SetCenter( const Vector3 & value ); + NIFLIB_API void SetCenter( const Vector4 & value ); /*! * Gets the current mass of this rigid body. @@ -273,12 +273,44 @@ public: */ NIFLIB_API void SetQualityType( MotionQuality value ); + // The initial deactivator type of the body. + // \return The current value. + NIFLIB_API DeactivatorType GetDeactivatorType() const; + + // The initial deactivator type of the body. + // \param[in] value The new value. + NIFLIB_API void SetDeactivatorType( const DeactivatorType & value ); + + // Usually set to 1 for fixed objects, or set to 2 for moving ones. Seems to + // always be same as Unknown Byte 1. + // \return The current value. + SolverDeactivation GetSolverDeactivation() const; + + // Usually set to 1 for fixed objects, or set to 2 for moving ones. Seems to + // always be same as Unknown Byte 1. + // \param[in] value The new value. + void SetSolverDeactivation( const SolverDeactivation & value ); + + //--END CUSTOM CODE--// protected: /*! Unknown. */ - array<5,float > unknown5Floats; + int unknownInt1; + /*! Unknown. */ + int unknownInt2; + /*! Unknown. */ + array<3,int > unknown3Ints; + /*! The collision response. See hkResponseType for hkpWorld default implementations. */ + hkResponseType collisionResponse_; + /*! Unknown */ + byte unknownByte; + /*! + * Lowers the frequency for processContactCallbacks. A value of 5 means that a + * callback is raised every 5th frame. + */ + unsigned short processContactCallbackDelay_; /*! Unknown. */ - array<4,unsigned short > unknown4Shorts; + array<2,unsigned short > unknown2Shorts; /*! Copy of Layer value? */ OblivionLayer layerCopy; /*! Copy of Col Filter value? */ @@ -289,35 +321,23 @@ protected: * A vector that moves the body by the specified amount. Only enabled in * bhkRigidBodyT objects. */ - Vector3 translation; - /*! - * This seems to often be 1 for single objects, or the first one in a - * a linked object group. This may be due to those objects often being - * bhkRigidBodyT as well. - */ - float unknownFloat00; + Vector4 translation; /*! * The rotation Yaw/Pitch/Roll to apply to the body. Only enabled in bhkRigidBodyT * objects. */ QuaternionXYZW rotation; /*! Linear velocity. */ - Vector3 linearVelocity; - /*! Unknown. */ - float unknownFloat01; + Vector4 linearVelocity; /*! Angular velocity. */ - Vector3 angularVelocity; - /*! Unknown. */ - float unknownFloat02; + Vector4 angularVelocity; /*! Defines how the mass is distributed among the body. */ InertiaMatrix inertia; /*! * This seems to be used to relocate the object's center of mass. Useful for * balancing objects in contraints. */ - Vector3 center; - /*! Unknown float. */ - float unknownFloat03; + Vector4 center; /*! The body's mass. */ float mass; /*! @@ -329,34 +349,48 @@ protected: float angularDamping; /*! The body's friction. */ float friction; - /*! The body's restitution (elasticity). */ + /*! + * The body's restitution (elasticity). + * If the restitution is not 0.0 the object will need extra CPU for all + * new collisions. + * Try to set restitution to 0 for maximum performance (e.g. collapsing + * buildings) + */ float restitution; /*! Maximal linear velocity. */ float maxLinearVelocity; /*! Maximal angular velocity. Pi x 10? */ float maxAngularVelocity; - /*! Penetration depth. */ + /*! + * The maximum allowed penetration for this object. + * This is a hint to the engine to see how much CPU the engine should + * invest to keep this object from penetrating. + * A good choice is 5% - 20% of the smallest diameter of the object. + */ float penetrationDepth; /*! Motion system? Overrides Quality when on Keyframed? */ MotionSystem motionSystem; - /*! - * Usually set to 1 for fixed objects, or set to 2 for moving ones. Seems to - * always be same as Unknown Byte 2. - */ - byte unknownByte1; + /*! The initial deactivator type of the body. */ + DeactivatorType deactivatorType; /*! * Usually set to 1 for fixed objects, or set to 2 for moving ones. Seems to * always be same as Unknown Byte 1. */ - byte unknownByte2; + SolverDeactivation solverDeactivation; /*! The motion type. Determines quality of motion? */ MotionQuality qualityType; - /*! Unknown. */ - unsigned int unknownInt6; - /*! Unknown. */ - unsigned int unknownInt7; - /*! Unknown. */ - unsigned int unknownInt8; + /*! + * This is a user flag which you can set to give you a hint as to which objects to + * remove from the simulation if the memory overhead becomes too high. + */ + unsigned int autoRemoveLevel; + /*! + * Requests a number of extra fields in each hkpContactPointProperties for this + * rigid body. + */ + unsigned int userDatasInContactPointProperties_; + /*! Ps3 only */ + unsigned int forceCollideOntoPpu_; /*! The number of constraints this object is bound to. */ mutable unsigned int numConstraints; /*! Unknown. */ diff --git a/include/obj/bhkStiffSpringConstraint.h b/include/obj/bhkStiffSpringConstraint.h index 17f47ae55012320975d63b70572401c486ab476d..38fe8c756b5bc0ade15f5b633e5f52db7659220b 100644 --- a/include/obj/bhkStiffSpringConstraint.h +++ b/include/obj/bhkStiffSpringConstraint.h @@ -56,9 +56,9 @@ public: //--END CUSTOM CODE--// protected: /*! Pivot A. */ - Float4 pivotA; + Vector4 pivotA; /*! Pivot B. */ - Float4 pivotB; + Vector4 pivotB; /*! Length. */ float length; public: diff --git a/src/NIF_IO.cpp b/src/NIF_IO.cpp index 7787b0dc5276b9c7b7ccede355585fdda24f196d..96ec1b20907b70aeb5c672ecdc6f63033e3d0293 100644 --- a/src/NIF_IO.cpp +++ b/src/NIF_IO.cpp @@ -468,6 +468,21 @@ void NifStream( Vector3 const & val, ostream& out, const NifInfo & info ) { WriteFloat( val.z, out ); }; +//Vector3 +void NifStream( Vector4 & val, istream& in, const NifInfo & info ) { + val.x = ReadFloat( in ); + val.y = ReadFloat( in ); + val.z = ReadFloat( in ); + val.w = ReadFloat( in ); +}; + +void NifStream( Vector4 const & val, ostream& out, const NifInfo & info ) { + WriteFloat( val.x, out ); + WriteFloat( val.y, out ); + WriteFloat( val.z, out ); + WriteFloat( val.w, out ); +}; + //Float2 void NifStream( Float2 & val, istream& in, const NifInfo & info ) { val.data[0] = ReadFloat( in ); diff --git a/src/gen/enums.cpp b/src/gen/enums.cpp index eb0e3d6837a63ce1de6ec0faf5e5ccced747f053..d11d02f7d2b7797e0cc683a6cd7ec433aba32682 100644 --- a/src/gen/enums.cpp +++ b/src/gen/enums.cpp @@ -63,6 +63,51 @@ ostream & operator<<( ostream & out, CollisionMode const & val ) { } +//--DeactivatorType--// + +void NifStream( DeactivatorType & val, istream& in, const NifInfo & info ) { + byte temp; + NifStream( temp, in, info ); + val = DeactivatorType(temp); +} + +void NifStream( DeactivatorType const & val, ostream& out, const NifInfo & info ) { + NifStream( (byte)(val), out, info ); +} + +ostream & operator<<( ostream & out, DeactivatorType const & val ) { + switch ( val ) { + case DEACTIVATOR_INVALID: return out << "DEACTIVATOR_INVALID"; + case DEACTIVATOR_NEVER: return out << "DEACTIVATOR_NEVER"; + case DEACTIVATOR_SPATIAL: return out << "DEACTIVATOR_SPATIAL"; + default: return out << "Invalid Value! - " << (unsigned int)(val); + } +} + + +//--hkResponseType--// + +void NifStream( hkResponseType & val, istream& in, const NifInfo & info ) { + byte temp; + NifStream( temp, in, info ); + val = hkResponseType(temp); +} + +void NifStream( hkResponseType const & val, ostream& out, const NifInfo & info ) { + NifStream( (byte)(val), out, info ); +} + +ostream & operator<<( ostream & out, hkResponseType const & val ) { + switch ( val ) { + case RESPONSE_INVALID: return out << "RESPONSE_INVALID"; + case RESPONSE_SIMPLE_CONTACT: return out << "RESPONSE_SIMPLE_CONTACT"; + case RESPONSE_REPORTING: return out << "RESPONSE_REPORTING"; + case RESPONSE_NONE: return out << "RESPONSE_NONE"; + default: return out << "Invalid Value! - " << (unsigned int)(val); + } +} + + //--TexTransform--// void NifStream( TexTransform & val, istream& in, const NifInfo & info ) { @@ -378,6 +423,31 @@ ostream & operator<<( ostream & out, OblivionLayer const & val ) { } +//--SolverDeactivation--// + +void NifStream( SolverDeactivation & val, istream& in, const NifInfo & info ) { + byte temp; + NifStream( temp, in, info ); + val = SolverDeactivation(temp); +} + +void NifStream( SolverDeactivation const & val, ostream& out, const NifInfo & info ) { + NifStream( (byte)(val), out, info ); +} + +ostream & operator<<( ostream & out, SolverDeactivation const & val ) { + switch ( val ) { + case SOLVER_DEACTIVATION_INVALID: return out << "SOLVER_DEACTIVATION_INVALID"; + case SOLVER_DEACTIVATION_OFF: return out << "SOLVER_DEACTIVATION_OFF"; + case SOLVER_DEACTIVATION_LOW: return out << "SOLVER_DEACTIVATION_LOW"; + case SOLVER_DEACTIVATION_MEDIUM: return out << "SOLVER_DEACTIVATION_MEDIUM"; + case SOLVER_DEACTIVATION_HIGH: return out << "SOLVER_DEACTIVATION_HIGH"; + case SOLVER_DEACTIVATION_MAX: return out << "SOLVER_DEACTIVATION_MAX"; + default: return out << "Invalid Value! - " << (unsigned int)(val); + } +} + + //--FaceDrawMode--// void NifStream( FaceDrawMode & val, istream& in, const NifInfo & info ) { @@ -601,10 +671,16 @@ void NifStream( MotionSystem const & val, ostream& out, const NifInfo & info ) { ostream & operator<<( ostream & out, MotionSystem const & val ) { switch ( val ) { + case MO_SYS_INVALID: return out << "MO_SYS_INVALID"; + case MO_SYS_DYNAMIC: return out << "MO_SYS_DYNAMIC"; case MO_SYS_SPHERE: return out << "MO_SYS_SPHERE"; + case MO_SYS_SPHERE_INERTIA: return out << "MO_SYS_SPHERE_INERTIA"; case MO_SYS_BOX: return out << "MO_SYS_BOX"; - case MO_SYS_KEYFRAMED_BIPED: return out << "MO_SYS_KEYFRAMED_BIPED"; + case MO_SYS_BOX_STABILIZED: return out << "MO_SYS_BOX_STABILIZED"; case MO_SYS_KEYFRAMED: return out << "MO_SYS_KEYFRAMED"; + case MO_SYS_FIXED: return out << "MO_SYS_FIXED"; + case MO_SYS_THIN_BOX: return out << "MO_SYS_THIN_BOX"; + case MO_SYS_CHARACTER: return out << "MO_SYS_CHARACTER"; default: return out << "Invalid Value! - " << (unsigned int)(val); } } @@ -790,15 +866,16 @@ void NifStream( MotionQuality const & val, ostream& out, const NifInfo & info ) ostream & operator<<( ostream & out, MotionQuality const & val ) { switch ( val ) { - case MO_QUAL_MOVING: return out << "MO_QUAL_MOVING"; + case MO_QUAL_INVALID: return out << "MO_QUAL_INVALID"; case MO_QUAL_FIXED: return out << "MO_QUAL_FIXED"; case MO_QUAL_KEYFRAMED: return out << "MO_QUAL_KEYFRAMED"; - case MO_QUAL_MOVING2: return out << "MO_QUAL_MOVING2"; - case MO_QUAL_MOVING3: return out << "MO_QUAL_MOVING3"; + case MO_QUAL_DEBRIS: return out << "MO_QUAL_DEBRIS"; + case MO_QUAL_MOVING: return out << "MO_QUAL_MOVING"; case MO_QUAL_CRITICAL: return out << "MO_QUAL_CRITICAL"; case MO_QUAL_BULLET: return out << "MO_QUAL_BULLET"; case MO_QUAL_USER: return out << "MO_QUAL_USER"; - case MO_QUAL_NULL: return out << "MO_QUAL_NULL"; + case MO_QUAL_CHARACTER: return out << "MO_QUAL_CHARACTER"; + case MO_QUAL_KEYFRAMED_REPORT: return out << "MO_QUAL_KEYFRAMED_REPORT"; default: return out << "Invalid Value! - " << (unsigned int)(val); } } diff --git a/src/nif_math.cpp b/src/nif_math.cpp index 5a34c2e36bf5b7b45ee7e42503b0c9b6541948b6..9ee0ca018e6f6eb451b92af234379fbc7a69e856 100644 --- a/src/nif_math.cpp +++ b/src/nif_math.cpp @@ -145,6 +145,120 @@ Vector3 Vector3::CrossProduct( const Vector3 & rh) const { // return *this; //} + +/* +* Vector4 Methods +*/ +Vector4::Vector4( const Float4 & v) { + x = v[0]; y = v[1]; z = v[2]; w = v[3]; +} + +float Vector4::Magnitude() const { + return sqrt( x * x + y * y + z * z + w * w ); +} + +Vector4 Vector4::Normalized() const { + Vector4 v(*this); + float m = Magnitude(); + return Vector4( + x / m, //x + y / m, //y + z / m, //z + w / m + ); +} + +Vector4 Vector4::operator+( const Vector4 & rh) const { + Vector4 v(*this); + v += rh; + return v; +} + +Vector4 & Vector4::operator+=( const Vector4 & rh ) { + x += rh.x; + y += rh.y; + z += rh.z; + w += rh.w; + return *this; +} + +Vector4 Vector4::operator-( const Vector4 & rh) const { + Vector4 v(*this); + v -= rh; + return v; +} + +Vector4 & Vector4::operator-=( const Vector4 & rh ) { + x -= rh.x; + y -= rh.y; + z -= rh.z; + w -= rh.w; + return *this; +} + +Vector4 Vector4::operator*( const float & rh) const { + Vector4 v(*this); + v *= rh; + return v; +} + +Vector4 & Vector4::operator*=( const float & rh) { + x *= rh; + y *= rh; + z *= rh; + w *= rh; + return *this; +} + +Vector4 Vector4::operator/( const float & rh ) const { + Vector4 v(*this); + v /= rh; + return v; +} + +Vector4 & Vector4::operator/=( const float & rh ) { + x /= rh; + y /= rh; + z /= rh; + w /= rh; + return *this; +} + +bool Vector4::operator==( const Vector4 & rh) const { + if (rh.x == x && rh.y == y && rh.z == z && rh.w == w) + return true; + else + return false; +} + +bool Vector4::operator!=( const Vector4 & rh) const { + if (rh.x == x && rh.y == y && rh.z == z && rh.w == w) + return false; + else + return true; +} + +float & Vector4::operator[](int n) { + switch (n) { + case 0: return x; + case 1: return y; + case 2: return z; + case 3: return w; + default: throw runtime_error("Invalid index"); + } +} + +float Vector4::operator[](int n) const { + switch (n) { + case 0: return x; + case 1: return y; + case 2: return z; + case 3: return w; + default: throw runtime_error("Invalid index"); + } +} + + /* * Matrix22 Methods */ diff --git a/src/obj/NiSkinPartition.cpp b/src/obj/NiSkinPartition.cpp index e03f340dd2a349d441ffa70a9da935ad7cc498e9..44597b05b976141e1b82aca0606816fcd4bc347d 100644 --- a/src/obj/NiSkinPartition.cpp +++ b/src/obj/NiSkinPartition.cpp @@ -748,7 +748,7 @@ static bool containsBones( BoneList& a, BoneList& b ) { return true; } template <typename I, typename V> -int indexOf(I begin, I end, const V& val) { +size_t indexOf(I begin, I end, const V& val) { return std::distance(begin, std::find(begin, end, val)); } diff --git a/src/obj/bhkConvexVerticesShape.cpp b/src/obj/bhkConvexVerticesShape.cpp index 24d77e9f1b27a47bb993db086d814892dd2221a4..4b242b177548f490891cd64b0f179f472c46322d 100644 --- a/src/obj/bhkConvexVerticesShape.cpp +++ b/src/obj/bhkConvexVerticesShape.cpp @@ -157,7 +157,7 @@ vector<Vector3> bhkConvexVerticesShape::GetNormals() const { //Remove any bad triangles vector<Vector3> good_normals; for ( unsigned i = 0; i < normals.size(); ++i ) { - const Float4 & t = normals[i]; + const Vector4 & t = normals[i]; Vector3 v(t[0], t[1], t[2]); good_normals.push_back(v); } @@ -172,7 +172,7 @@ vector<Vector3> bhkConvexVerticesShape::GetVertices() const { //Remove any bad triangles vector<Vector3> good_vertices; for ( unsigned i = 0; i < vertices.size(); ++i ) { - const Float4 & t = vertices[i]; + const Vector4 & t = vertices[i]; Vector3 v(t[0], t[1], t[2]); good_vertices.push_back(v); } @@ -195,7 +195,7 @@ void bhkConvexVerticesShape::SetVertices( const vector<Vector3> & in ) vertices.resize(size); for (int i=0; i<size; ++i) { - Float4 &f = vertices[i]; + Vector4 &f = vertices[i]; const Vector3 &v = in[i]; f[0] = v.x; f[1] = v.y; @@ -210,7 +210,7 @@ void bhkConvexVerticesShape::SetNormals( const vector<Vector3> & in ) normals.resize(size); for (int i=0; i<size; ++i) { - Float4 &f = normals[i]; + Vector4 &f = normals[i]; const Vector3 &v = in[i]; f[0] = v.x; f[1] = v.y; @@ -228,17 +228,17 @@ void bhkConvexVerticesShape::SetDistToCenter( const vector<float> & in ) normals.resize(size); for (int i=0; i<size; ++i) { - Float4 &f = normals[i]; + Vector4 &f = normals[i]; f[3] = in[i]; } } -vector<Float4> bhkConvexVerticesShape::GetNormalsAndDist() const +vector<Vector4> bhkConvexVerticesShape::GetNormalsAndDist() const { return normals; } -void bhkConvexVerticesShape::SetNormalsAndDist(const vector<Float4>& value) +void bhkConvexVerticesShape::SetNormalsAndDist(const vector<Vector4>& value) { normals = value; } diff --git a/src/obj/bhkRigidBody.cpp b/src/obj/bhkRigidBody.cpp index 65b44d2ccafc5fcc99bbeb193ab9b2bf53b1f42f..c3bf7b654a928303e6f2bef3dfe65f802d183c44 100644 --- a/src/obj/bhkRigidBody.cpp +++ b/src/obj/bhkRigidBody.cpp @@ -22,7 +22,7 @@ using namespace Niflib; //Definition of TYPE constant const Type bhkRigidBody::TYPE("bhkRigidBody", &bhkEntity::TYPE ); -bhkRigidBody::bhkRigidBody() : layerCopy((OblivionLayer)1), colFilterCopy((byte)0), unknownFloat00(0.0f), unknownFloat01(0.0f), unknownFloat02(0.0f), unknownFloat03(0.0f), mass(0.0f), linearDamping(0.1f), angularDamping(0.1f), friction(0.3f), restitution(0.3f), maxLinearVelocity(250.0f), maxAngularVelocity(31.415926535f), penetrationDepth(0.15f), motionSystem((MotionSystem)7), unknownByte1((byte)1), unknownByte2((byte)1), qualityType((MotionQuality)1), unknownInt6((unsigned int)0), unknownInt7((unsigned int)0), unknownInt8((unsigned int)0), numConstraints((unsigned int)0), unknownInt9((unsigned int)0) { +bhkRigidBody::bhkRigidBody() : unknownInt1((int)0), unknownInt2((int)0x7c37a201), collisionResponse_((hkResponseType)1), unknownByte((byte)0xbe), processContactCallbackDelay_((unsigned short)0xffff), unknown2Shorts(2,(unsigned short)35899,(unsigned short)16336), layerCopy((OblivionLayer)1), colFilterCopy((byte)0), unknown7Shorts(7,(unsigned short)0,(unsigned short)21280,(unsigned short)2481,(unsigned short)62977,(unsigned short)65535,(unsigned short)44,(unsigned short)0), mass(1.0f), linearDamping(0.0f), angularDamping(0.05f), friction(0.5f), restitution(0.4f), maxLinearVelocity(200.0f), maxAngularVelocity(200.0f), penetrationDepth(0.15f), motionSystem((MotionSystem)1), deactivatorType((DeactivatorType)1), solverDeactivation((SolverDeactivation)1), qualityType((MotionQuality)0), autoRemoveLevel((unsigned int)0), userDatasInContactPointProperties_((unsigned int)0), forceCollideOntoPpu_((unsigned int)0), numConstraints((unsigned int)0), unknownInt9((unsigned int)0) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// } @@ -46,11 +46,16 @@ void bhkRigidBody::Read( istream& in, list<unsigned int> & link_stack, const Nif unsigned int block_num; bhkEntity::Read( in, link_stack, info ); - for (unsigned int i1 = 0; i1 < 5; i1++) { - NifStream( unknown5Floats[i1], in, info ); + NifStream( unknownInt1, in, info ); + NifStream( unknownInt2, in, info ); + for (unsigned int i1 = 0; i1 < 3; i1++) { + NifStream( unknown3Ints[i1], in, info ); }; - for (unsigned int i1 = 0; i1 < 4; i1++) { - NifStream( unknown4Shorts[i1], in, info ); + NifStream( collisionResponse_, in, info ); + NifStream( unknownByte, in, info ); + NifStream( processContactCallbackDelay_, in, info ); + for (unsigned int i1 = 0; i1 < 2; i1++) { + NifStream( unknown2Shorts[i1], in, info ); }; NifStream( layerCopy, in, info ); NifStream( colFilterCopy, in, info ); @@ -58,15 +63,12 @@ void bhkRigidBody::Read( istream& in, list<unsigned int> & link_stack, const Nif NifStream( unknown7Shorts[i1], in, info ); }; NifStream( translation, in, info ); - NifStream( unknownFloat00, in, info ); NifStream( rotation.x, in, info ); NifStream( rotation.y, in, info ); NifStream( rotation.z, in, info ); NifStream( rotation.w, in, info ); NifStream( linearVelocity, in, info ); - NifStream( unknownFloat01, in, info ); NifStream( angularVelocity, in, info ); - NifStream( unknownFloat02, in, info ); NifStream( inertia.m11, in, info ); NifStream( inertia.m12, in, info ); NifStream( inertia.m13, in, info ); @@ -80,7 +82,6 @@ void bhkRigidBody::Read( istream& in, list<unsigned int> & link_stack, const Nif NifStream( inertia.m33, in, info ); NifStream( inertia.m34, in, info ); NifStream( center, in, info ); - NifStream( unknownFloat03, in, info ); NifStream( mass, in, info ); NifStream( linearDamping, in, info ); NifStream( angularDamping, in, info ); @@ -90,12 +91,12 @@ void bhkRigidBody::Read( istream& in, list<unsigned int> & link_stack, const Nif NifStream( maxAngularVelocity, in, info ); NifStream( penetrationDepth, in, info ); NifStream( motionSystem, in, info ); - NifStream( unknownByte1, in, info ); - NifStream( unknownByte2, in, info ); + NifStream( deactivatorType, in, info ); + NifStream( solverDeactivation, in, info ); NifStream( qualityType, in, info ); - NifStream( unknownInt6, in, info ); - NifStream( unknownInt7, in, info ); - NifStream( unknownInt8, in, info ); + NifStream( autoRemoveLevel, in, info ); + NifStream( userDatasInContactPointProperties_, in, info ); + NifStream( forceCollideOntoPpu_, in, info ); NifStream( numConstraints, in, info ); constraints.resize(numConstraints); for (unsigned int i1 = 0; i1 < constraints.size(); i1++) { @@ -114,11 +115,16 @@ void bhkRigidBody::Write( ostream& out, const map<NiObjectRef,unsigned int> & li bhkEntity::Write( out, link_map, info ); numConstraints = (unsigned int)(constraints.size()); - for (unsigned int i1 = 0; i1 < 5; i1++) { - NifStream( unknown5Floats[i1], out, info ); + NifStream( unknownInt1, out, info ); + NifStream( unknownInt2, out, info ); + for (unsigned int i1 = 0; i1 < 3; i1++) { + NifStream( unknown3Ints[i1], out, info ); }; - for (unsigned int i1 = 0; i1 < 4; i1++) { - NifStream( unknown4Shorts[i1], out, info ); + NifStream( collisionResponse_, out, info ); + NifStream( unknownByte, out, info ); + NifStream( processContactCallbackDelay_, out, info ); + for (unsigned int i1 = 0; i1 < 2; i1++) { + NifStream( unknown2Shorts[i1], out, info ); }; NifStream( layerCopy, out, info ); NifStream( colFilterCopy, out, info ); @@ -126,15 +132,12 @@ void bhkRigidBody::Write( ostream& out, const map<NiObjectRef,unsigned int> & li NifStream( unknown7Shorts[i1], out, info ); }; NifStream( translation, out, info ); - NifStream( unknownFloat00, out, info ); NifStream( rotation.x, out, info ); NifStream( rotation.y, out, info ); NifStream( rotation.z, out, info ); NifStream( rotation.w, out, info ); NifStream( linearVelocity, out, info ); - NifStream( unknownFloat01, out, info ); NifStream( angularVelocity, out, info ); - NifStream( unknownFloat02, out, info ); NifStream( inertia.m11, out, info ); NifStream( inertia.m12, out, info ); NifStream( inertia.m13, out, info ); @@ -148,7 +151,6 @@ void bhkRigidBody::Write( ostream& out, const map<NiObjectRef,unsigned int> & li NifStream( inertia.m33, out, info ); NifStream( inertia.m34, out, info ); NifStream( center, out, info ); - NifStream( unknownFloat03, out, info ); NifStream( mass, out, info ); NifStream( linearDamping, out, info ); NifStream( angularDamping, out, info ); @@ -158,12 +160,12 @@ void bhkRigidBody::Write( ostream& out, const map<NiObjectRef,unsigned int> & li NifStream( maxAngularVelocity, out, info ); NifStream( penetrationDepth, out, info ); NifStream( motionSystem, out, info ); - NifStream( unknownByte1, out, info ); - NifStream( unknownByte2, out, info ); + NifStream( deactivatorType, out, info ); + NifStream( solverDeactivation, out, info ); NifStream( qualityType, out, info ); - NifStream( unknownInt6, out, info ); - NifStream( unknownInt7, out, info ); - NifStream( unknownInt8, out, info ); + NifStream( autoRemoveLevel, out, info ); + NifStream( userDatasInContactPointProperties_, out, info ); + NifStream( forceCollideOntoPpu_, out, info ); NifStream( numConstraints, out, info ); for (unsigned int i1 = 0; i1 < constraints.size(); i1++) { if ( info.version < VER_3_3_0_13 ) { @@ -190,8 +192,10 @@ std::string bhkRigidBody::asString( bool verbose ) const { unsigned int array_output_count = 0; out << bhkEntity::asString(); numConstraints = (unsigned int)(constraints.size()); + out << " Unknown Int 1: " << unknownInt1 << endl; + out << " Unknown Int 2: " << unknownInt2 << endl; array_output_count = 0; - for (unsigned int i1 = 0; i1 < 5; i1++) { + for (unsigned int i1 = 0; i1 < 3; i1++) { if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; break; @@ -199,11 +203,14 @@ std::string bhkRigidBody::asString( bool verbose ) const { if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { break; }; - out << " Unknown 5 Floats[" << i1 << "]: " << unknown5Floats[i1] << endl; + out << " Unknown 3 Ints[" << i1 << "]: " << unknown3Ints[i1] << endl; array_output_count++; }; + out << " Collision Response?: " << collisionResponse_ << endl; + out << " Unknown Byte: " << unknownByte << endl; + out << " Process Contact Callback Delay?: " << processContactCallbackDelay_ << endl; array_output_count = 0; - for (unsigned int i1 = 0; i1 < 4; i1++) { + for (unsigned int i1 = 0; i1 < 2; i1++) { if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; break; @@ -211,7 +218,7 @@ std::string bhkRigidBody::asString( bool verbose ) const { if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { break; }; - out << " Unknown 4 Shorts[" << i1 << "]: " << unknown4Shorts[i1] << endl; + out << " Unknown 2 Shorts[" << i1 << "]: " << unknown2Shorts[i1] << endl; array_output_count++; }; out << " Layer Copy: " << layerCopy << endl; @@ -229,15 +236,12 @@ std::string bhkRigidBody::asString( bool verbose ) const { array_output_count++; }; out << " Translation: " << translation << endl; - out << " Unknown Float 00: " << unknownFloat00 << endl; out << " x: " << rotation.x << endl; out << " y: " << rotation.y << endl; out << " z: " << rotation.z << endl; out << " w: " << rotation.w << endl; out << " Linear Velocity: " << linearVelocity << endl; - out << " Unknown Float 01: " << unknownFloat01 << endl; out << " Angular Velocity: " << angularVelocity << endl; - out << " Unknown Float 02: " << unknownFloat02 << endl; out << " m11: " << inertia.m11 << endl; out << " m12: " << inertia.m12 << endl; out << " m13: " << inertia.m13 << endl; @@ -251,7 +255,6 @@ std::string bhkRigidBody::asString( bool verbose ) const { out << " m33: " << inertia.m33 << endl; out << " m34: " << inertia.m34 << endl; out << " Center: " << center << endl; - out << " Unknown Float 03: " << unknownFloat03 << endl; out << " Mass: " << mass << endl; out << " Linear Damping: " << linearDamping << endl; out << " Angular Damping: " << angularDamping << endl; @@ -261,12 +264,12 @@ std::string bhkRigidBody::asString( bool verbose ) const { out << " Max Angular Velocity: " << maxAngularVelocity << endl; out << " Penetration Depth: " << penetrationDepth << endl; out << " Motion System: " << motionSystem << endl; - out << " Unknown Byte 1: " << unknownByte1 << endl; - out << " Unknown Byte 2: " << unknownByte2 << endl; + out << " Deactivator Type: " << deactivatorType << endl; + out << " Solver Deactivation: " << solverDeactivation << endl; out << " Quality Type: " << qualityType << endl; - out << " Unknown Int 6: " << unknownInt6 << endl; - out << " Unknown Int 7: " << unknownInt7 << endl; - out << " Unknown Int 8: " << unknownInt8 << endl; + out << " Auto Remove Level: " << autoRemoveLevel << endl; + out << " User Datas In Contact Point Properties?: " << userDatasInContactPointProperties_ << endl; + out << " Force Collide Onto Ppu?: " << forceCollideOntoPpu_ << endl; out << " Num Constraints: " << numConstraints << endl; array_output_count = 0; for (unsigned int i1 = 0; i1 < constraints.size(); i1++) { @@ -320,11 +323,11 @@ void bhkRigidBody::SetLayerCopy( OblivionLayer value ) { layerCopy = value; } -Vector3 bhkRigidBody::GetTranslation() const { +Vector4 bhkRigidBody::GetTranslation() const { return translation; } -void bhkRigidBody::SetTranslation( const Vector3 & value ) { +void bhkRigidBody::SetTranslation( const Vector4 & value ) { translation = value; } @@ -336,19 +339,19 @@ void bhkRigidBody::SetRotation( const QuaternionXYZW & value ) { rotation = value; } -Vector3 bhkRigidBody::GetLinearVelocity() const { +Vector4 bhkRigidBody::GetLinearVelocity() const { return linearVelocity; } -void bhkRigidBody::SetLinearVelocity( const Vector3 & value ) { +void bhkRigidBody::SetLinearVelocity( const Vector4 & value ) { linearVelocity = value; } -Vector3 bhkRigidBody::GetAngularVelocity() const { +Vector4 bhkRigidBody::GetAngularVelocity() const { return angularVelocity; } -void bhkRigidBody::SetAngularVelocity( const Vector3 & value ) { +void bhkRigidBody::SetAngularVelocity( const Vector4 & value ) { angularVelocity = value; } @@ -384,11 +387,11 @@ void bhkRigidBody::SetInertia( const array<12,float>& value ) { inertia.m34 = value[11]; } -Vector3 bhkRigidBody::GetCenter() const { +Vector4 bhkRigidBody::GetCenter() const { return center; } -void bhkRigidBody::SetCenter( const Vector3 & value ) { +void bhkRigidBody::SetCenter( const Vector4 & value ) { center = value; } @@ -472,4 +475,20 @@ void bhkRigidBody::SetQualityType( MotionQuality value ) { qualityType = value; } +DeactivatorType bhkRigidBody::GetDeactivatorType() const { + return deactivatorType; +} + +void bhkRigidBody::SetDeactivatorType( const DeactivatorType & value ) { + deactivatorType = value; +} + +SolverDeactivation bhkRigidBody::GetSolverDeactivation() const { + return solverDeactivation; +} + +void bhkRigidBody::SetSolverDeactivation( const SolverDeactivation & value ) { + solverDeactivation = value; +} + //--END CUSTOM CODE--//