Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into meshageddon
Browse files Browse the repository at this point in the history
  • Loading branch information
JMPZ11 committed Jun 23, 2024
2 parents 013745a + 65b7723 commit c6679f6
Show file tree
Hide file tree
Showing 17 changed files with 888 additions and 291 deletions.
89 changes: 86 additions & 3 deletions build/nif.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,14 @@
<field name="a" type="byte">Alpha color component.</field>
</struct>

<struct name="ByteColor4BGRA" size="4" convertible="Color4" module="NiMain">
A color with alpha (blue, green, red, alpha).
<field name="b" type="byte">Blue color component.</field>
<field name="g" type="byte">Green color component.</field>
<field name="r" type="byte">Red color component.</field>
<field name="a" type="byte">Alpha color component.</field>
</struct>

<struct name="FilePath" module="NiMain">
A string that contains the path to a file.
<field name="String" type="SizedString" until="20.0.0.5">The normal string.</field>
Expand Down Expand Up @@ -1767,6 +1775,13 @@
<field name="z" type="hfloat">Third coordinate.</field>
</struct>

<struct name="ShortVector3" size="6" convertible="Vector3" module="NiMain">
A vector in 3D space (x,y,z).
<field name="x" type="short">First coordinate.</field>
<field name="y" type="short">Second coordinate.</field>
<field name="z" type="short">Third coordinate.</field>
</struct>

<struct name="UshortVector3" size="6" convertible="Vector3" module="NiMain">
A vector in 3D space (x,y,z).
<field name="x" type="ushort">First coordinate.</field>
Expand All @@ -1789,6 +1804,21 @@
<field name="w" type="float">Fourth coordinate.</field>
</struct>

<struct name="ByteVector4" size="4" convertible="Vector4" module="NiMain">
A 4-dimensional vector.
<field name="x" type="normbyte">First coordinate.</field>
<field name="y" type="normbyte">Second coordinate.</field>
<field name="z" type="normbyte">Third coordinate.</field>
<field name="w" type="normbyte">Fourth coordinate.</field>
</struct>

<struct name="UDecVector4" size="4" convertible="Vector4" module="NiMain">
<field name="x" type="byte">First coordinate.</field>
<field name="y" type="byte">Second coordinate.</field>
<field name="z" type="byte">Third coordinate.</field>
<field name="w" type="byte">Fourth coordinate.</field>
</struct>

<struct name="Quaternion" size="16" module="NiMain">
A quaternion.
<field name="w" type="float" default="1.0">The w-coordinate.</field>
Expand Down Expand Up @@ -9184,16 +9214,69 @@
<field name="Unknown Structs" type="UnknownWeakReferenceStruct" length="Num Unknown 1" />
</niobject>

<struct name="BSMeshTriangles" module="BSMain" versions="#STF#">
<field name="Indices Size" type="uint" />
<field name="Triangles" type="Triangle" length="Indices Size #DIV# 3" />
</struct>

<struct name="BSMeshlet" module="BSMain" versions="#STF#">
<field name="Vertex Count" type="uint" />
<field name="Vertex Offset" type="uint" />
<field name="Triangle Count" type="uint" />
<field name="Triangle Offset" type="uint" />
</struct>

<struct name="BSCullData" module="BSMain" versions="#STF#">
<field name="Bounding Sphere" type="NiBound" cond="#ARG# #LT# 2" />
<field name="Normal Cone" type="ByteVector4" cond="#ARG# #LT# 2" />
<field name="Apex Offset" type="float" cond="#ARG# #LT# 2" />
<field name="Bound Min Max" type="float" length="6" cond="#ARG# #GTE# 2" />
</struct>

<struct name="BSBoneWeight" module="BSMain" versions="#STF#">
<field name="Bone" type="ushort" />
<field name="Weight" type="ushort" />
</struct>

<struct name="BSMeshData" module="BSMain" versions="#STF#">
<field name="Version" type="uint" />
<field name="Indices Size" type="uint" />
<field name="Triangles" type="Triangle" length="Indices Size #DIV# 3" />
<field name="Scale" type="float">Vertex coordinate scale * 32767.0</field>
<field name="Weights Per Vertex" type="uint" />
<field name="Num Verts" type="uint" />
<field name="Vertices" type="ShortVector3" length="Num Verts" />
<field name="Num UVs" type="uint" />
<field name="UVs" type="HalfTexCoord" length="Num UVs" />
<field name="Num UVs 2" type="uint" />
<field name="UVs 2" type="HalfTexCoord" length="Num UVs 2" cond="Num UVs 2 #GT# 0" />
<field name="Num Vertex Colors" type="uint" />
<field name="Vertex Colors" type="ByteColor4BGRA" length="Num Vertex Colors" cond="Num Vertex Colors #GT# 0" />
<field name="Num Normals" type="uint" />
<field name="Normals" type="UDecVector4" length="Num Normals" />
<field name="Num Tangents" type="uint" />
<field name="Tangents" type="UDecVector4" length="Num Tangents" />
<field name="Num Weights" type="uint" />
<field name="Weights" type="BSBoneWeight" length="Num Weights" cond="Num Weights #GT# 0" />
<field name="Num LODs" type="uint" cond="Version #GTE# 1" />
<field name="LODs" type="BSMeshTriangles" length="Num LODs" cond="(Version #GTE# 1) #AND# (Num LODs #GT# 0)" />
<field name="Num Meshlets" type="uint" />
<field name="Meshlets" type="BSMeshlet" length="Num Meshlets" cond="Num Meshlets #GT# 0" />
<field name="Num Cull Data" type="uint" />
<field name="Cull Data" type="BSCullData" arg="Version" length="Num Cull Data" cond="Num Cull Data #GT# 0" />
</struct>

<struct name="BSMesh" module="BSMain" versions="#STF#">
<field name="Indices Size" type="uint" />
<field name="Num Verts" type="uint" />
<field name="Flags" type="uint" />
<field name="Mesh Path" type="SizedString" />
<field name="Mesh Path" type="SizedString" cond="#ARG# #EQ# 0" />
<field name="Mesh Data" type="BSMeshData" cond="#ARG# #NEQ# 0" />
</struct>

<struct name="BSMeshArray" module="BSMain" versions="#STF#">
<field name="Has Mesh" type="byte" />
<field name="Mesh" type="BSMesh" cond="Has Mesh #EQ# 1" />
<field name="Mesh" type="BSMesh" arg="#ARG# #BITAND# 512" cond="Has Mesh #EQ# 1" />
</struct>

<niobject name="BSGeometry" inherit="NiAVObject" module="BSMain" versions="#STF#">
Expand All @@ -9202,7 +9285,7 @@
<field name="Skin" type="Ref" template="NiObject" />
<field name="Shader Property" type="Ref" template="BSShaderProperty" />
<field name="Alpha Property" type="Ref" template="NiAlphaProperty" />
<field name="Meshes" type="BSMeshArray" length="4" />
<field name="Meshes" type="BSMeshArray" arg="Flags" length="4" />
</niobject>

<niobject name="SkinAttach" inherit="NiExtraData" module="BSMain" versions="#STF#">
Expand Down
83 changes: 83 additions & 0 deletions src/data/niftypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,24 @@ class HalfVector3 : public Vector3
}
};

class ShortVector3 : public Vector3
{
public:
//! Default constructor
ShortVector3()
{
xyz[0] = xyz[1] = xyz[2] = 0.0;
}
//! Constructor
ShortVector3( float x, float y, float z ) : Vector3( x, y, z )
{
}

ShortVector3( Vector3 v ) : Vector3( v )
{
}
};

class UshortVector3 : public Vector3
{
public:
Expand Down Expand Up @@ -570,6 +588,14 @@ class Vector4
xyzw[2] = v3[2];
xyzw[3] = w;
}
inline Vector4 & operator=( const FloatVector4 & v )
{
xyzw[0] = v[0];
xyzw[1] = v[1];
xyzw[2] = v[2];
xyzw[3] = v[3];
return *this;
}
//! Add-equals operator
Vector4 & operator+=( const Vector4 & v )
{
Expand Down Expand Up @@ -768,6 +794,44 @@ inline Vector3::Vector3( const Vector4 & v4 )
xyz[2] = v4[2];
}

class ByteVector4 : public Vector4
{
public:
ByteVector4() : Vector4( FloatVector4( 0.0f, 0.0f, 1.0f, 1.0f ) )
{
}

ByteVector4( const std::uint32_t & v ) : Vector4( ( FloatVector4(v) - 127.5f ) / 127.5f )
{
}

inline operator std::uint32_t() const
{
return std::uint32_t( FloatVector4( *this ) * 127.5f + 127.5f );
}
};

class UDecVector4 : public Vector4
{
public:
UDecVector4() : Vector4( FloatVector4( 0.0f, 0.0f, 1.0f, 1.0f ) )
{
}

UDecVector4( const std::uint32_t & v ) : Vector4( FloatVector4::convertX10Y10Z10( v ) )
{
xyzw[3] = ( !(v & 0x80000000U) ? 1.0f : -1.0f );
}

inline operator std::uint32_t() const
{
std::uint32_t v = FloatVector4( *this ).convertToX10Y10Z10();
if ( xyzw[3] < 0.0f )
v = v | 0x80000000U;
return v;
}
};

//! A quaternion
class Quat
{
Expand Down Expand Up @@ -1535,6 +1599,21 @@ class ByteColor4 : public Color4
}
};

class ByteColor4BGRA : public Color4
{
public:
//! Default constructor
ByteColor4BGRA() { rgba[0] = rgba[1] = rgba[2] = rgba[3] = 1.0; }
ByteColor4BGRA( const std::uint32_t & c )
: Color4( FloatVector4(c).shuffleValues(0xC6) / 255.0f )
{
}
inline operator std::uint32_t() const
{
return std::uint32_t( FloatVector4(*this).shuffleValues(0xC6) * 255.0f );
}
};


inline Color3::Color3( const Color4 & c4 )
{
Expand Down Expand Up @@ -1971,12 +2050,16 @@ inline QDataStream & operator>>( QDataStream & ds, BSVertexDesc & d )
Q_DECLARE_TYPEINFO( Vector2, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Vector3, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( HalfVector3, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( ShortVector3, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( UshortVector3, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( ByteVector3, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Vector4, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( ByteVector4, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( UDecVector4, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Color3, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Color4, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( ByteColor4, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( ByteColor4BGRA, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Triangle, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Quat, Q_MOVABLE_TYPE );
Q_DECLARE_TYPEINFO( Matrix, Q_MOVABLE_TYPE );
Expand Down
Loading

0 comments on commit c6679f6

Please sign in to comment.