MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / Load

Function Load

plugins/Assimp/Plugin.cpp:86–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
87{
88 Nz::String streamPath = stream.GetPath();
89
90 FileIOUserdata userdata;
91 userdata.originalFilePath = (!streamPath.IsEmpty()) ? streamPath.GetConstBuffer() : StreamPath;
92 userdata.originalStream = &stream;
93
94 aiFileIO fileIO;
95 fileIO.CloseProc = StreamCloser;
96 fileIO.OpenProc = StreamOpener;
97 fileIO.UserData = reinterpret_cast<char*>(&userdata);
98
99 unsigned int postProcess = aiProcess_CalcTangentSpace | aiProcess_JoinIdenticalVertices
100 | aiProcess_MakeLeftHanded | aiProcess_Triangulate
101 | aiProcess_RemoveComponent | aiProcess_GenSmoothNormals
102 | aiProcess_SplitLargeMeshes | aiProcess_LimitBoneWeights
103 | aiProcess_ImproveCacheLocality | aiProcess_RemoveRedundantMaterials
104 | aiProcess_FixInfacingNormals | aiProcess_SortByPType
105 | aiProcess_FindInvalidData | aiProcess_GenUVCoords
106 | aiProcess_TransformUVCoords | aiProcess_OptimizeMeshes
107 | aiProcess_OptimizeGraph | aiProcess_FlipWindingOrder
108 | aiProcess_Debone;
109
110 if (parameters.optimizeIndexBuffers)
111 postProcess |= aiProcess_ImproveCacheLocality;
112
113 double smoothingAngle = 80.f;
114 parameters.custom.GetDoubleParameter("AssimpLoader_SmoothingAngle", &smoothingAngle);
115
116 long long triangleLimit = 1'000'000;
117 parameters.custom.GetIntegerParameter("AssimpLoader_TriangleLimit", &triangleLimit);
118
119 long long vertexLimit = 1'000'000;
120 parameters.custom.GetIntegerParameter("AssimpLoader_VertexLimit", &vertexLimit);
121
122 aiPropertyStore* properties = aiCreatePropertyStore();
123 aiSetImportPropertyFloat(properties, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, float(smoothingAngle));
124 aiSetImportPropertyInteger(properties, AI_CONFIG_PP_LBW_MAX_WEIGHTS, 4);
125 aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SBP_REMOVE, ~aiPrimitiveType_TRIANGLE); //< We only want triangles
126 aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, int(triangleLimit));
127 aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SLM_VERTEX_LIMIT, int(vertexLimit));
128 aiSetImportPropertyInteger(properties, AI_CONFIG_PP_RVC_FLAGS, aiComponent_COLORS);
129
130 const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties);
131 aiReleasePropertyStore(properties);
132
133 if (!scene)
134 {
135 NazaraError("Assimp failed to import file: " + Nz::String(aiGetErrorString()));
136 return false;
137 }
138
139 std::set<Nz::String> joints;
140
141 bool animatedMesh = false;
142 if (parameters.animated)
143 {

Callers

nothing calls this directly

Calls 15

ProcessJointsFunction · 0.85
IsEmptyMethod · 0.80
GetConstBufferMethod · 0.80
GetDoubleParameterMethod · 0.80
GetIntegerParameterMethod · 0.80
GetJointMethod · 0.80
CreateStaticMethod · 0.80
TransformMethod · 0.80
GenerateAABBMethod · 0.80
SetMaterialIndexMethod · 0.80
SetParameterMethod · 0.80
AddSubMeshMethod · 0.80

Tested by

no test coverage detected