@@ -153,6 +153,13 @@ struct DRJIT_EXTRA_EXPORT TraversableBase : public nanobind::intrusive_base {
153
153
static_assert ( \
154
154
std::is_base_of<drjit::TraversableBase, \
155
155
std::remove_pointer_t <decltype (this )>>::value); \
156
+ /* \
157
+ * Only traverse the objects for frozen functions, since \
158
+ * accidentally traversing the scene in loops or vcalls can cause \
159
+ * issues. \
160
+ */ \
161
+ if (!jit_flag (JitFlag::EnableObjectTraversal)) \
162
+ return ; \
156
163
if constexpr (!std::is_same_v<Base, drjit::TraversableBase>) \
157
164
Base::traverse_1_cb_ro (payload, fn); \
158
165
DRJIT_MAP (DR_TRAVERSE_MEMBER_RO, __VA_ARGS__) \
@@ -169,6 +176,16 @@ struct DRJIT_EXTRA_EXPORT TraversableBase : public nanobind::intrusive_base {
169
176
#define DR_TRAVERSE_CB_RW (Base, ...) \
170
177
void traverse_1_cb_rw (void *payload, \
171
178
drjit::detail::traverse_callback_rw fn) override { \
179
+ static_assert ( \
180
+ std::is_base_of<drjit::TraversableBase, \
181
+ std::remove_pointer_t <decltype (this )>>::value); \
182
+ /* \
183
+ * Only traverse the objects for frozen functions, since \
184
+ * accidentally traversing the scene in loops or vcalls can cause \
185
+ * issues. \
186
+ */ \
187
+ if (!jit_flag (JitFlag::EnableObjectTraversal)) \
188
+ return ; \
172
189
if constexpr (!std::is_same_v<Base, drjit::TraversableBase>) \
173
190
Base::traverse_1_cb_rw (payload, fn); \
174
191
DRJIT_MAP (DR_TRAVERSE_MEMBER_RW, __VA_ARGS__) \
0 commit comments