|
3 | 3 | ////////////////////////////////////////////////////////////////////// |
4 | 4 |
|
5 | 5 | #include "stdafx.h" |
| 6 | + |
| 7 | +#include <tbb/blocked_range.h> |
| 8 | +#include <tbb/parallel_for.h> |
| 9 | + |
6 | 10 | #include "HOM.h" |
7 | 11 | #include "occRasterizer.h" |
8 | 12 | #include "xrEngine/GameFont.h" |
@@ -93,26 +97,30 @@ void CHOM::Load() |
93 | 97 |
|
94 | 98 | // Create RASTER-triangles |
95 | 99 | m_pTris = xr_alloc<occTri>(u32(CL.getTS())); |
96 | | - for (u32 it = 0; it < CL.getTS(); it++) |
| 100 | + |
| 101 | + tbb::parallel_for(tbb::blocked_range<u32>(0, CL.getTS()), [&](const auto& range) |
97 | 102 | { |
98 | | - CDB::TRI& clT = CL.getT()[it]; |
99 | | - occTri& rT = m_pTris[it]; |
100 | | - Fvector& v0 = CL.getV()[clT.verts[0]]; |
101 | | - Fvector& v1 = CL.getV()[clT.verts[1]]; |
102 | | - Fvector& v2 = CL.getV()[clT.verts[2]]; |
103 | | - rT.adjacent[0] = (0xffffffff == adjacency[3 * it + 0]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 0]); |
104 | | - rT.adjacent[1] = (0xffffffff == adjacency[3 * it + 1]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 1]); |
105 | | - rT.adjacent[2] = (0xffffffff == adjacency[3 * it + 2]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 2]); |
106 | | - rT.flags = clT.dummy; |
107 | | - rT.area = Area(v0, v1, v2); |
108 | | - if (rT.area < EPS_L) |
| 103 | + for (u32 it = range.begin(); it != range.end(); ++it) |
109 | 104 | { |
110 | | - Msg("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)", VPUSH(v0), VPUSH(v1), VPUSH(v2)); |
| 105 | + CDB::TRI& clT = CL.getT()[it]; |
| 106 | + occTri& rT = m_pTris[it]; |
| 107 | + Fvector& v0 = CL.getV()[clT.verts[0]]; |
| 108 | + Fvector& v1 = CL.getV()[clT.verts[1]]; |
| 109 | + Fvector& v2 = CL.getV()[clT.verts[2]]; |
| 110 | + rT.adjacent[0] = (0xffffffff == adjacency[3 * it + 0]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 0]); |
| 111 | + rT.adjacent[1] = (0xffffffff == adjacency[3 * it + 1]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 1]); |
| 112 | + rT.adjacent[2] = (0xffffffff == adjacency[3 * it + 2]) ? ((occTri*)(-1)) : (m_pTris + adjacency[3 * it + 2]); |
| 113 | + rT.flags = clT.dummy; |
| 114 | + rT.area = Area(v0, v1, v2); |
| 115 | + |
| 116 | + if (rT.area < EPS_L) |
| 117 | + Msg("! Invalid HOM triangle (%f,%f,%f)-(%f,%f,%f)-(%f,%f,%f)", VPUSH(v0), VPUSH(v1), VPUSH(v2)); |
| 118 | + |
| 119 | + rT.plane.build(v0, v1, v2); |
| 120 | + rT.skip = 0; |
| 121 | + rT.center.add(v0, v1).add(v2).div(3.f); |
111 | 122 | } |
112 | | - rT.plane.build(v0, v1, v2); |
113 | | - rT.skip = 0; |
114 | | - rT.center.add(v0, v1).add(v2).div(3.f); |
115 | | - } |
| 123 | + }); |
116 | 124 |
|
117 | 125 | // Create AABB-tree |
118 | 126 | m_pModel = new CDB::MODEL(); |
|
0 commit comments