Skip to content

Commit

Permalink
Removing surface_id from triangle reference
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Jan 17, 2024
1 parent dfa64f8 commit 81ef877
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions include/xdg/geometry_data.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#ifndef _XDG_GEOMETRY_DATA_H
#define _XDG_GEOMETRY_DATA_H

#include "xdg/constants.h"

namespace xdg
{

struct MeshManager; // Forward declaration
struct TriangleRef; // Forward declaration

struct GeometryUserData {
MeshID surface_id {ID_NONE}; //! ID of the surface this geometry data is associated with
MeshManager* mesh_manager {nullptr}; //! Pointer to the mesh manager for this geometry
TriangleRef* tri_ref_buffer {nullptr}; //! Pointer to the triangles in the geometry
double box_bump; //! Bump distance for the bounding boxes in this geometry
Expand Down
2 changes: 2 additions & 0 deletions include/xdg/ray_tracing_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace xdg
{

using TreeID = RTCScene;

class RayTracer {
// Constructors
public:
Expand Down
1 change: 0 additions & 1 deletion include/xdg/triangle_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct TriangleRef; // Forward declaration
// TODO: could be a more generic primitive ref?
struct TriangleRef {
MeshID triangle_id {ID_NONE};
MeshID surface_id {ID_NONE};
Sense sense {Sense::UNSET};
};

Expand Down
9 changes: 5 additions & 4 deletions src/ray_tracing_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ RayTracer::register_volume(const std::shared_ptr<MeshManager> mesh_manager,
for (int i = 0; i < surface_elements.size(); ++i) {
auto& triangle_ref = triangle_storage[i + storage_offset];
triangle_ref.triangle_id = surface_elements[i];
triangle_ref.surface_id = surface_id;
triangle_ref.sense = triangle_sense;
}
storage_offset += surface_elements.size();
Expand Down Expand Up @@ -86,6 +85,7 @@ RayTracer::register_volume(const std::shared_ptr<MeshManager> mesh_manager,
this->surface_to_geometry_map_[surface] = surface_geometry;

GeometryUserData surface_data;
surface_data.surface_id = surface;
surface_data.mesh_manager = mesh_manager.get();
surface_data.tri_ref_buffer = tri_ref_ptr + buffer_start;
user_data_map_[surface_geometry] = surface_data;
Expand Down Expand Up @@ -255,9 +255,10 @@ Direction RayTracer::get_normal(MeshID surface,
TriangleRef triangle_ref;
closest(surface_vols.first, point, dist, triangle_ref);

if (triangle_ref.surface_id != surface) {
fatal_error("Point {} was closest to surface {}, not surface {}, in volume {}.", point, triangle_ref.surface_id, surface, surface_vols.first);
}
// TODO: bring this back when we have a better way to handle this
// if (geom_data.surface_id != surface) {
// fatal_error("Point {} was closest to surface {}, not surface {}, in volume {}.", point, geom_data.surface_id, surface, surface_vols.first);
// }
element = triangle_ref.triangle_id;
}

Expand Down

0 comments on commit 81ef877

Please sign in to comment.