MCPcopy Create free account
hub / github.com/LuxCoreRender/LuxCore / CompileGeometry

Method CompileGeometry

src/slg/engines/pathoclbase/compilegeometry.cpp:38–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void CompiledScene::CompileGeometry() {
39 SLG_LOG("Compile Geometry");
40 wasGeometryCompiled = true;
41
42 const u_int objCount = scene->objDefs.GetSize();
43
44 const double tStart = WallClockTime();
45
46 // Clear vectors
47 verts.resize(0);
48 normals.resize(0);
49 uvs.resize(0);
50 cols.resize(0);
51 alphas.resize(0);
52 tris.resize(0);
53 meshDescs.resize(0);
54
55 //--------------------------------------------------------------------------
56 // Translate geometry
57 //--------------------------------------------------------------------------
58
59 // Not using boost::unordered_map because the key is an ExtMesh pointer
60 map<ExtMesh *, u_int, bool (*)(Mesh *, Mesh *)> definedMeshs(MeshPtrCompare);
61
62 slg::ocl::Mesh newMeshDesc;
63 newMeshDesc.vertsOffset = 0;
64 newMeshDesc.trisOffset = 0;
65 newMeshDesc.normalsOffset = 0;
66 newMeshDesc.uvsOffset = 0;
67 newMeshDesc.colsOffset = 0;
68 newMeshDesc.alphasOffset = 0;
69 // newMeshDesc.trans is initialized below (different for each mesh type)
70
71 slg::ocl::Mesh currentMeshDesc;
72 for (u_int i = 0; i < objCount; ++i) {
73 const ExtMesh *mesh = scene->objDefs.GetSceneObject(i)->GetExtMesh();
74
75 bool isExistingInstance;
76 switch (mesh->GetType()) {
77 case TYPE_EXT_TRIANGLE_INSTANCE: {
78 // It is an instanced mesh
79 ExtInstanceTriangleMesh *imesh = (ExtInstanceTriangleMesh *)mesh;
80
81 // Check if is one of the already defined meshes
82 map<ExtMesh *, u_int, bool (*)(Mesh *, Mesh *)>::iterator it = definedMeshs.find(imesh->GetExtTriangleMesh());
83 if (it == definedMeshs.end()) {
84 // It is a new one
85 currentMeshDesc = newMeshDesc;
86
87 newMeshDesc.vertsOffset += mesh->GetTotalVertexCount();
88 newMeshDesc.trisOffset += mesh->GetTotalTriangleCount();
89 if (mesh->HasNormals())
90 newMeshDesc.normalsOffset += mesh->GetTotalVertexCount();
91 if (mesh->HasUVs())
92 newMeshDesc.uvsOffset += mesh->GetTotalVertexCount();
93 if (mesh->HasColors())
94 newMeshDesc.colsOffset += mesh->GetTotalVertexCount();
95 if (mesh->HasAlphas())

Callers

nothing calls this directly

Calls 15

WallClockTimeFunction · 0.85
GetSceneObjectMethod · 0.80
GetMotionSystemMethod · 0.80
GetVertexMethod · 0.80
GetTrianglesMethod · 0.80
InverseFunction · 0.50
TransformClass · 0.50
ToStringFunction · 0.50
GetSizeMethod · 0.45
resizeMethod · 0.45
GetExtMeshMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected