Skip to content

Commit 4cbe7ff

Browse files
committed
Fixed broken intersector logic when tracing instances
1 parent e85b2b8 commit 4cbe7ff

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

RadeonRays/src/accelerator/bvh2.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ THE SOFTWARE.
2727
#include <vector>
2828

2929
#include "../primitive/mesh.h"
30+
#include "../primitive/instance.h"
3031

3132
namespace RadeonRays
3233
{
@@ -57,7 +58,7 @@ namespace RadeonRays
5758

5859
protected:
5960
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> >;
6162

6263
// Constant values
6364
enum Constants
@@ -147,7 +148,7 @@ namespace RadeonRays
147148
static inline void SetPrimitive(
148149
Node &node,
149150
std::uint32_t index,
150-
std::pair<const Mesh *, std::size_t> ref);
151+
std::pair<const Shape *, std::size_t> ref);
151152

152153
static inline bool IsInternal(const Node &node);
153154
static inline std::uint32_t GetChildIndex(const Node &node, std::uint8_t idx);
@@ -273,7 +274,7 @@ namespace RadeonRays
273274
_mm_store_ps(&aabb_max[current_face].x, pmax);
274275
_mm_store_ps(&aabb_centroid[current_face].x, centroid);
275276

276-
metadata[current_face] = std::make_pair(mesh, face_index);
277+
metadata[current_face] = std::make_pair(shape, face_index);
277278
}
278279
}
279280

@@ -329,10 +330,11 @@ namespace RadeonRays
329330
void Bvh2::SetPrimitive(
330331
Node &node,
331332
std::uint32_t index,
332-
std::pair<const Mesh *, std::size_t> ref)
333+
std::pair<const Shape *, std::size_t> ref)
333334
{
334-
auto mesh = ref.first;
335+
auto shape = ref.first;
335336
matrix worldmat, worldmatinv;
337+
auto mesh = static_cast<const Mesh *>(static_cast<const ShapeImpl *>(shape)->is_instance() ? static_cast<const Instance *>(shape)->GetBaseShape() : shape);
336338
mesh->GetTransform(worldmat, worldmatinv);
337339
auto face = mesh->GetFaceData()[ref.second];
338340
auto v0 = transform_point(mesh->GetVertexData()[face.idx[0]], worldmat);
@@ -347,7 +349,7 @@ namespace RadeonRays
347349
node.aabb_right_min_or_v2[0] = v2.x;
348350
node.aabb_right_min_or_v2[1] = v2.y;
349351
node.aabb_right_min_or_v2[2] = v2.z;
350-
node.mesh_id = mesh->GetId();
352+
node.mesh_id = shape->GetId();
351353
node.prim_id = static_cast<std::uint32_t>(ref.second);
352354
}
353355

RadeonRays/src/device/calc_intersection_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace RadeonRays
126126
m_intersector_string = "fatbvh";
127127
#else
128128
m_intersector.reset(new IntersectorLDS(m_device.get()));
129-
m_intersector_string = "bvh2";
129+
m_intersector_string = "fatbvh";
130130
#endif
131131
}
132132
}

0 commit comments

Comments
 (0)