Skip to content

Commit

Permalink
fix: Allow unsetting of source-ray tracing flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Oct 10, 2024
1 parent 93e68f5 commit e1dad56
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/rt/Rmakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RCSid: $Id: Rmakefile,v 2.96 2024/09/16 23:49:12 greg Exp $
# RCSid: $Id: Rmakefile,v 2.97 2024/10/10 21:02:52 greg Exp $
#
# Compiles for ray tracing programs.
#
Expand Down Expand Up @@ -458,7 +458,8 @@ oocbuild.o: oocbuild.c oocbuild.h oocsort.h oococt.h
oocnn.o: oocnn.c oocnn.h oococt.h oocsort.h

RtraceSimulManager.o rxpiece.o rxpmain.o \
rxtmain.o rxtrace.o: RtraceSimulManager.h
rxtmain.o rxtrace.o: RtraceSimulManager.h \
../common/abitmap.h

RpictSimulManager.o rxpiece.o rxpmain.o: RpictSimulManager.h \
../common/view.h ../common/depthcodec.h ../common/abitmap.h
Expand Down
3 changes: 1 addition & 2 deletions src/rt/RpictSimulManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* RCSid $Id: RpictSimulManager.h,v 2.9 2024/09/16 23:49:13 greg Exp $ */
/* RCSid $Id: RpictSimulManager.h,v 2.10 2024/10/10 21:02:52 greg Exp $ */
/*
* RpictSimulManager.h
*
Expand All @@ -13,7 +13,6 @@
#include "RtraceSimulManager.h"
#include "view.h"
#include "depthcodec.h"
#include "abitmap.h"

/// Data type flags for pixel access and output
enum RenderDataType {
Expand Down
18 changes: 14 additions & 4 deletions src/rt/RtraceSimulManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: RtraceSimulManager.cpp,v 2.17 2024/09/16 19:18:32 greg Exp $";
static const char RCSid[] = "$Id: RtraceSimulManager.cpp,v 2.18 2024/10/10 21:02:52 greg Exp $";
#endif
/*
* RtraceSimulManager.cpp
Expand Down Expand Up @@ -288,11 +288,21 @@ RtraceSimulManager::UpdateMode()
int misMatch = rtFlags ^ curFlags;
// updates based on toggled flags
if (misMatch & RTtraceSources) {
int sn = nsources;
if (rtFlags & RTtraceSources) {
for (int sn = 0; sn < nsources; sn++)
srcFollowed.NewBitMap(nsources);
while (sn--) {
if (source[sn].sflags & SFOLLOW)
continue;
source[sn].sflags |= SFOLLOW;
} else // cannot undo this...
rtFlags |= RTtraceSources;
srcFollowed.Set(sn);
}
} else {
while (sn--)
if (srcFollowed.Check(sn))
source[sn].sflags &= ~SFOLLOW;
srcFollowed.NewBitMap(0);
}
}
if (misMatch & RTdoFIFO && FlushQueue() < 0)
return false;
Expand Down
8 changes: 5 additions & 3 deletions src/rt/RtraceSimulManager.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* RCSid $Id: RtraceSimulManager.h,v 2.14 2024/09/16 19:18:32 greg Exp $ */
/* RCSid $Id: RtraceSimulManager.h,v 2.15 2024/10/10 21:02:52 greg Exp $ */
/*
* RtraceSimulManager.h
*
Expand All @@ -13,6 +13,7 @@
#define RtraceSimulManager_h

#include "ray.h"
#include "abitmap.h"

extern char * octname; // global octree name

Expand Down Expand Up @@ -40,7 +41,7 @@ class RadSimulManager {
bool LoadOctree(const char *octn);
/// Prepare header from previous input (or clear)
/// Normally called during octree load
bool NewHeader(const char *inspec=NULL);
bool NewHeader(const char *inspec = NULL);
/// Add a line to header (adds newline if none)
bool AddHeader(const char *str);
/// Append program line to header
Expand Down Expand Up @@ -83,6 +84,7 @@ class RtraceSimulManager : public RadSimulManager {
RayReportCall * traceCall; // call for every ray in tree
void * tcData; // client data for traced rays
int curFlags; // current operating flags
ABitMap srcFollowed; // source flags changed
// Call-back for global ray-tracing context
static void RTracer(RAY *r);
// Call-back for FIFO
Expand Down Expand Up @@ -129,7 +131,7 @@ class RtraceSimulManager : public RadSimulManager {
cookedCall = cb;
ccData = cb ? cd : NULL;
}
/// Set/change trace callback
/// Set/change trace callback (before threading)
void SetTraceCall(RayReportCall *cb, void *cd = NULL) {
traceCall = cb;
tcData = cb ? cd : NULL;
Expand Down

0 comments on commit e1dad56

Please sign in to comment.