MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / Load

Method Load

ogsr_engine/Layers/xrRender/HOM.cpp:49–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void CHOM::Load()
50{
51 // Find and open file
52 string_path fName;
53 FS.update_path(fName, fsgame::level, fsgame::level_files::level_hom);
54 if (!FS.exist(fName))
55 {
56 Msg(" WARNING: Occlusion map '%s' not found.", fName);
57 return;
58 }
59 Msg("* Loading HOM: %s", fName);
60
61 IReader* fs = FS.r_open(fName);
62
63 // Load tris and merge them
64 CDB::Collector CL;
65
66 {
67 IReader* S = fs->open_chunk(1);
68 while (!S->eof())
69 {
70 HOM_poly P;
71 S->r(&P, sizeof(P));
72 CL.add_face_packed_D(P.v1, P.v2, P.v3, P.flags, 0.01f);
73 }
74 S->close();
75 }
76
77 FS.r_close(fs);
78
79 // Determine adjacency
80 xr_vector<u32> adjacency;
81 CL.calc_adjacency(adjacency);
82
83 // Create RASTER-triangles
84 m_pTris = xr_alloc<occTri>(CL.getTS());
85
86 for (size_t it{}; it < CL.getTS(); it++)
87 {
88 const CDB::TRI& clT = CL.getT()[it];
89 occTri& rT = m_pTris[it];
90 const Fvector& v0 = CL.getV()[clT.verts[0]];
91 const Fvector& v1 = CL.getV()[clT.verts[1]];
92 const Fvector& v2 = CL.getV()[clT.verts[2]];
93 rT.adjacent[0] = (0xffffffff == adjacency[3 * it + 0]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 0]);
94 rT.adjacent[1] = (0xffffffff == adjacency[3 * it + 1]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 1]);
95 rT.adjacent[2] = (0xffffffff == adjacency[3 * it + 2]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 2]);
96 rT.flags = static_cast<u32>(clT.dummy);
97 rT.area = area(v0, v1, v2);
98 if (rT.area < EPS_L)
99 {
100 Msg("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)", VPUSH(v0), VPUSH(v1), VPUSH(v2));
101 }
102 rT.plane.build(v0, v1, v2);
103 rT.skip = 0;
104 rT.center.add(v0, v1).add(v2).div(3.f);
105 }
106

Callers 6

OnAssetsChangedMethod · 0.45
Instance_LoadMethod · 0.45
OnDeviceCreateMethod · 0.45
LoadShaderFileMethod · 0.45
_CreateTextureMethod · 0.45
DeferredUploadMethod · 0.45

Calls 15

MsgFunction · 0.85
areaFunction · 0.85
existMethod · 0.80
r_openMethod · 0.80
eofMethod · 0.80
add_face_packed_DMethod · 0.80
r_closeMethod · 0.80
calc_adjacencyMethod · 0.80
update_pathMethod · 0.45
open_chunkMethod · 0.45
rMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected