@@ -27,6 +27,7 @@ THE SOFTWARE.
27
27
#include < vector>
28
28
29
29
#include " ../primitive/mesh.h"
30
+ #include " ../primitive/instance.h"
30
31
31
32
namespace RadeonRays
32
33
{
@@ -57,7 +58,7 @@ namespace RadeonRays
57
58
58
59
protected:
59
60
using RefArray = std::vector<std::uint32_t >;
60
- using MetaDataArray = std::vector<std::pair<const Mesh *, std::size_t > >;
61
+ using MetaDataArray = std::vector<std::pair<const Shape *, std::size_t > >;
61
62
62
63
// Constant values
63
64
enum Constants
@@ -147,7 +148,7 @@ namespace RadeonRays
147
148
static inline void SetPrimitive (
148
149
Node &node,
149
150
std::uint32_t index,
150
- std::pair<const Mesh *, std::size_t > ref);
151
+ std::pair<const Shape *, std::size_t > ref);
151
152
152
153
static inline bool IsInternal (const Node &node);
153
154
static inline std::uint32_t GetChildIndex (const Node &node, std::uint8_t idx);
@@ -273,7 +274,7 @@ namespace RadeonRays
273
274
_mm_store_ps (&aabb_max[current_face].x , pmax);
274
275
_mm_store_ps (&aabb_centroid[current_face].x , centroid);
275
276
276
- metadata[current_face] = std::make_pair (mesh , face_index);
277
+ metadata[current_face] = std::make_pair (shape , face_index);
277
278
}
278
279
}
279
280
@@ -329,10 +330,11 @@ namespace RadeonRays
329
330
void Bvh2::SetPrimitive (
330
331
Node &node,
331
332
std::uint32_t index,
332
- std::pair<const Mesh *, std::size_t > ref)
333
+ std::pair<const Shape *, std::size_t > ref)
333
334
{
334
- auto mesh = ref.first ;
335
+ auto shape = ref.first ;
335
336
matrix worldmat, worldmatinv;
337
+ auto mesh = static_cast <const Mesh *>(static_cast <const ShapeImpl *>(shape)->is_instance () ? static_cast <const Instance *>(shape)->GetBaseShape () : shape);
336
338
mesh->GetTransform (worldmat, worldmatinv);
337
339
auto face = mesh->GetFaceData ()[ref.second ];
338
340
auto v0 = transform_point (mesh->GetVertexData ()[face.idx [0 ]], worldmat);
@@ -347,7 +349,7 @@ namespace RadeonRays
347
349
node.aabb_right_min_or_v2 [0 ] = v2.x ;
348
350
node.aabb_right_min_or_v2 [1 ] = v2.y ;
349
351
node.aabb_right_min_or_v2 [2 ] = v2.z ;
350
- node.mesh_id = mesh ->GetId ();
352
+ node.mesh_id = shape ->GetId ();
351
353
node.prim_id = static_cast <std::uint32_t >(ref.second );
352
354
}
353
355
0 commit comments