diff --git a/CommonLibF4/include/RE/Bethesda/BSGraphics.h b/CommonLibF4/include/RE/Bethesda/BSGraphics.h index 0c9d23c7..643c1b4a 100644 --- a/CommonLibF4/include/RE/Bethesda/BSGraphics.h +++ b/CommonLibF4/include/RE/Bethesda/BSGraphics.h @@ -398,10 +398,12 @@ namespace RE { return ((desc >> 44) & a_flag) != 0; } + void SetFlag(Vertex::Flags a_flag) { desc |= (static_cast(a_flag) << 44); } + void ClearFlag(Vertex::Flags a_flag) { desc &= ~(static_cast(a_flag) << 44); @@ -411,6 +413,7 @@ namespace RE { return (desc >> (4 * static_cast(a_attribute) + 2)) & 0x3C; } + void SetAttributeOffset(Vertex::Attribute a_attribute, std::uint32_t a_offset) { if (a_attribute != Vertex::Attribute::VA_POSITION) { @@ -420,6 +423,7 @@ namespace RE desc = lhs | rhs; } } + void ClearAttributeOffsets() { desc &= Vertex::Masks::DESC_MASK_OFFSET; @@ -429,6 +433,7 @@ namespace RE { return static_cast((desc & Vertex::Masks::DESC_MASK_OFFSET) >> 44); } + void SetFlags(Vertex::Flags a_flags) { desc |= (static_cast(a_flags) << 44) | (desc & Vertex::Masks::DESC_MASK_FLAGS); @@ -439,7 +444,6 @@ namespace RE return (desc & 0xF) * 4; } - private: // members std::uint64_t desc; // 00 }; diff --git a/CommonLibF4/include/RE/Bethesda/BSGraphicsUtility.h b/CommonLibF4/include/RE/Bethesda/BSGraphicsUtility.h new file mode 100644 index 00000000..cb23bd4a --- /dev/null +++ b/CommonLibF4/include/RE/Bethesda/BSGraphicsUtility.h @@ -0,0 +1,60 @@ +#pragma once + +namespace RE +{ + class NiPoint2; + class NiPoint3; + class NiColorA; +} + +namespace RE::BSGraphics::Utility +{ + inline std::uint64_t PackVertexData( + std::uint32_t a_numVertices, + NiPoint3* a_positions, + NiPoint2* a_texCoords0, + NiColorA* a_texCoords1, + NiPoint3* a_normals, + NiPoint3* a_binormals, + NiPoint3* a_tangents, + NiColorA* a_colors, + NiColorA* a_skinBoneWeights, + std::uint8_t* a_skinBoneIndices, + NiColorA* a_landscapeData1, + NiColorA* a_landscapeData2, + float* a_eyeData, + void* a_buffer, + std::uint32_t* a_bufferSize, + std::uint16_t* a_vertexMap, + std::uint32_t a_dynamicFlags, + std::uint16_t* a_tangentXBuffer, + std::uint32_t a_tangentXBufferStride) + { + using func_t = decltype(&PackVertexData); + static REL::Relocation func{ REL::ID(2277106) }; + return func(a_numVertices, a_positions, a_texCoords0, a_texCoords1, a_normals, a_binormals, a_tangents, a_colors, a_skinBoneWeights, a_skinBoneIndices, a_landscapeData1, a_landscapeData2, a_eyeData, a_buffer, a_bufferSize, a_vertexMap, a_dynamicFlags, a_tangentXBuffer, a_tangentXBufferStride); + + } + + inline void UnpackVertexData( + const std::uint8_t* a_vertices, + const std::uint16_t a_index, + const std::uint64_t a_vertexDesc, + NiPoint3* a_position, + NiPoint2* a_texCoord0, + NiPoint2* a_texCoord1, + NiPoint3* a_normal, + NiPoint3* a_binormal, + NiPoint3* a_tangent, + NiColorA* a_color, + NiColorA* a_skinBoneWeights, + std::uint8_t* a_boneIndex0, + std::uint8_t* a_boneIndex1, + std::uint8_t* a_boneIndex2, + std::uint8_t* a_boneIndex3) + { + using func_t = decltype(&UnpackVertexData); + static REL::Relocation func{ REL::ID(2277129) }; + func(a_vertices, a_index, a_vertexDesc, a_position, a_texCoord0, a_texCoord1, a_normal, a_binormal, a_tangent, a_color, a_skinBoneWeights, a_boneIndex0, a_boneIndex1, a_boneIndex2, a_boneIndex3); + } +} diff --git a/CommonLibF4/include/RE/Fallout.h b/CommonLibF4/include/RE/Fallout.h index bfa106c3..9f45708c 100644 --- a/CommonLibF4/include/RE/Fallout.h +++ b/CommonLibF4/include/RE/Fallout.h @@ -39,6 +39,7 @@ #include "RE/Bethesda/BSFixedString.h" #include "RE/Bethesda/BSGeometry.h" #include "RE/Bethesda/BSGraphics.h" +#include "RE/Bethesda/BSGraphicsUtility.h" #include "RE/Bethesda/BSHavok.h" #include "RE/Bethesda/BSInputDeviceManager.h" #include "RE/Bethesda/BSInputEventReceiver.h"