8
8
//
9
9
10
10
#include " StaticMeshDataPacker.h"
11
+ #include " MathUtils.h"
11
12
12
13
#include < assimp/postprocess.h>
13
14
#include < assimp/scene.h>
16
17
#include < utils/Logging.h>
17
18
18
19
#include < algorithm>
19
- #include < assimp/Importer.hpp>
20
20
#include < fstream>
21
21
22
22
enum RequestPathStage
@@ -50,7 +50,7 @@ static RequestPathStage GetRequestPathStage(const Siege::String& requestPath,
50
50
51
51
static void GetMeshData (const aiScene* scene,
52
52
const aiMesh* mesh,
53
- const aiMatrix4x4t<ai_real>& matrix ,
53
+ const Siege::Mat4& mat ,
54
54
OUT std::vector<Siege::BaseVertex>& vertices,
55
55
OUT std::vector<uint32_t >& indices)
56
56
{
@@ -59,8 +59,11 @@ static void GetMeshData(const aiScene* scene,
59
59
Siege::BaseVertex vertex {};
60
60
61
61
aiVector3t<ai_real> vert = mesh->mVertices [i];
62
- vert *= matrix;
63
- vertex.position = {vert.x , vert.y , vert.z };
62
+ Siege::Vec4 v = {vert.x , vert.y , vert.z , 1 .f };
63
+
64
+ v = mat * v;
65
+
66
+ vertex.position = {v.x , v.y , v.z };
64
67
65
68
aiVector3t<ai_real> norm = mesh->mNormals [i];
66
69
vertex.normal = {norm.x , norm.y , norm.z };
@@ -93,7 +96,7 @@ static void GetMeshesForNode(const aiScene* scene,
93
96
const aiNode* node,
94
97
const Siege::String& requestPath,
95
98
Siege::String currentPath,
96
- aiMatrix4x4t<ai_real> matrix,
99
+ Siege::Mat4 matrix,
97
100
OUT std::vector<Siege::BaseVertex>& vertices,
98
101
OUT std::vector<uint32_t >& indices)
99
102
{
@@ -109,7 +112,7 @@ static void GetMeshesForNode(const aiScene* scene,
109
112
110
113
if (nodePathStage == CHILD || nodePathStage == SELF)
111
114
{
112
- matrix *= node->mTransformation ;
115
+ matrix *= AssimptMat4ToMat4 ( node->mTransformation ) ;
113
116
}
114
117
115
118
for (uint32_t i = 0 ; i < node->mNumMeshes ; i++)
@@ -175,7 +178,7 @@ void* PackStaticMeshFile(const Siege::String& filePath, const Siege::String& ass
175
178
176
179
CC_LOG_INFO (" Reading static mesh for file {} with node path {}" , it->second , requestedNodePath)
177
180
178
- aiMatrix4x4t<ai_real> baseXform;
181
+ Siege::Mat4 baseXform = Siege::Mat4::Identity () ;
179
182
auto flipAxesIt = attributes.find (TOKEN_FLIP_AXES);
180
183
if (flipAxesIt != attributes.end ())
181
184
{
@@ -186,7 +189,7 @@ void* PackStaticMeshFile(const Siege::String& filePath, const Siege::String& ass
186
189
187
190
for (int32_t i = 0 ; i < flipAxesIt->second .Size (); ++i)
188
191
{
189
- aiVector3t<ai_real> scale { 1 .f , 1 .f , 1 .f };
192
+ Siege::Vec4 scale = { 1 . f , 1 .f , 1 .f , 1 .f };
190
193
switch (flipAxesIt->second [i])
191
194
{
192
195
case ' x' :
@@ -203,8 +206,7 @@ void* PackStaticMeshFile(const Siege::String& filePath, const Siege::String& ass
203
206
flipAxesIt->second [i])
204
207
break ;
205
208
}
206
- aiMatrix4x4t<ai_real> scalingMat;
207
- baseXform *= aiMatrix4x4t<ai_real>::Scaling (scale, scalingMat);
209
+ baseXform *= Siege::Mat4::Scale (scale);
208
210
}
209
211
}
210
212
0 commit comments