00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Elendt 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: TS_SweepNode.h ( TS Library, C++) 00015 * 00016 * COMMENTS: Classes to help with ray-intersection. In preparing for 00017 * ray-intersection, each node has the opportunity to build a 00018 * sweep list. 00019 * 00020 * Pre-Process: 00021 * The sweep root finder will ask the expression to build a sweep root list. 00022 * This will go through all it's children and: 00023 * a) Test each node for intersection with the ray (i.e. ray-prep) 00024 * b) Add the primitive to a sorted sweep list for the expression 00025 * 00026 * Root Finding: 00027 * - The sweep root finder needs to find the closest starting point for the 00028 * ray-intersection processing. So, it asks the expression. 00029 * - The expression takes it's first inactive sweep node and asks it for it's 00030 * closest node (this potentially recurses through additional expressions) 00031 * - The sweeper then tells the expression to cull any active sweep nodes and 00032 * add any nodes it needs. 00033 * 00034 * The sweep nodes are stored in a non-circular list (i.e. terminated by nulls 00035 * at both ends). 00036 * 00037 */ 00038 00039 #ifndef __TS_SweepNode__ 00040 #define __TS_SweepNode__ 00041 00042 #include "TS_API.h" 00043 class TS_MetaExpression; 00044 00045 class TS_API TS_SweepNode { 00046 public: 00047 // Before calling any of these functions with a non-negative thread 00048 // number, the thread pools MUST be initialized with a call to 00049 // setupThreads 00050 static TS_SweepNode *allocNode(TS_MetaExpression *prim, float t0, float t1, 00051 int threadNum = -1); 00052 static void freeList(TS_SweepNode *node, TS_SweepNode *last=0, 00053 int threadNum = -1); 00054 static void freeNode(TS_SweepNode *node, int threadNum = -1); 00055 static void destroyMemory(); 00056 00057 // Initializes multiple sweep node object pools to be used 00058 // by multiple threads 00059 static void setupThreads(int numThreads); 00060 00061 TS_MetaExpression *getPrim() const { return myPrim; } 00062 float getT0() const { return myT0; } 00063 float getT1() const { return myT1; } 00064 00065 TS_SweepNode *getNext() { return myNext; } 00066 00067 // Both of these methods return the new head 00068 TS_SweepNode *linkAtHead(TS_SweepNode *head); 00069 TS_SweepNode *unlink(TS_SweepNode *head); 00070 00071 // This function is used when we get the sorted list of sweep nodes. We 00072 // can quickly build the links without doing it one by one. 00073 void setLinks(TS_SweepNode *prev, TS_SweepNode *next) 00074 { 00075 myPrev = prev; 00076 myNext = next; 00077 } 00078 00079 private: 00080 TS_SweepNode *myPrev, *myNext; 00081 TS_MetaExpression *myPrim; 00082 float myT0, myT1; 00083 }; 00084 00085 #endif
1.5.9