HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TS_SweepNode.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TS_SweepNode.h ( TS Library, C++)
7  *
8  * COMMENTS: Classes to help with ray-intersection. In preparing for
9  * ray-intersection, each node has the opportunity to build a
10  * sweep list.
11  *
12  * Pre-Process:
13  * The sweep root finder will ask the expression to build a sweep root list.
14  * This will go through all it's children and:
15  * a) Test each node for intersection with the ray (i.e. ray-prep)
16  * b) Add the primitive to a sorted sweep list for the expression
17  *
18  * Root Finding:
19  * - The sweep root finder needs to find the closest starting point for the
20  * ray-intersection processing. So, it asks the expression.
21  * - The expression takes it's first inactive sweep node and asks it for it's
22  * closest node (this potentially recurses through additional expressions)
23  * - The sweeper then tells the expression to cull any active sweep nodes and
24  * add any nodes it needs.
25  *
26  * The sweep nodes are stored in a non-circular list (i.e. terminated by nulls
27  * at both ends).
28  *
29  */
30 
31 #ifndef __TS_SweepNode__
32 #define __TS_SweepNode__
33 
34 #include "TS_API.h"
35 class TS_MetaExpression;
36 
38 {
39 public:
40  // Before calling any of these functions with a non-negative thread
41  // number, the thread pools MUST be initialized with a call to
42  // setupThreads
43  static TS_SweepNode *allocNode(TS_MetaExpression *prim, float t0, float t1,
44  int threadNum = -1);
45  static void freeList(TS_SweepNode *node, TS_SweepNode *last=0,
46  int threadNum = -1);
47  static void freeNode(TS_SweepNode *node, int threadNum = -1);
48  static void destroyMemory();
49 
50  // Initializes multiple sweep node object pools to be used
51  // by multiple threads
52  static void setupThreads(int numThreads);
53 
54  TS_MetaExpression *getPrim() const { return myPrim; }
55  float getT0() const { return myT0; }
56  float getT1() const { return myT1; }
57 
58  TS_SweepNode *getNext() { return myNext; }
59 
60  // Both of these methods return the new head
61  TS_SweepNode *linkAtHead(TS_SweepNode *head);
62  TS_SweepNode *unlink(TS_SweepNode *head);
63 
64  // This function is used when we get the sorted list of sweep nodes. We
65  // can quickly build the links without doing it one by one.
66  void setLinks(TS_SweepNode *prev, TS_SweepNode *next)
67  {
68  myPrev = prev;
69  myNext = next;
70  }
71 
72 private:
73  TS_SweepNode *myPrev, *myNext;
74  TS_MetaExpression *myPrim;
75  float myT0, myT1;
76 };
77 
78 #endif
UT_StringArray JOINTS head
float getT0() const
Definition: TS_SweepNode.h:55
TS_MetaExpression * getPrim() const
Definition: TS_SweepNode.h:54
void setLinks(TS_SweepNode *prev, TS_SweepNode *next)
Definition: TS_SweepNode.h:66
#define TS_API
Definition: api.h:41
float getT1() const
Definition: TS_SweepNode.h:56
__hostdev__ uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5976
TS_SweepNode * getNext()
Definition: TS_SweepNode.h:58