Changeset 2752 for GTP/trunk


Ignore:
Timestamp:
06/10/08 15:48:44 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/CHC_revisited
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.cpp

    r2751 r2752  
    1 #if TOIMPLEMENT 
    2  
    31#include <queue> 
    42#include <stack> 
    53#include "Bvh.h" 
    6 #include "yare.h" 
    7 #include "PerfTimer.h" 
    8 #include "Camera.h" 
    9 #include "Settings.h" 
    10 #include "Context.h" 
    11 #include "TriangleBvh.h" 
    12 #include "NodeGeometry.h" 
    13 #include "Viewer.h" 
    144 
    155#include <fstream> 
     
    188 
    199 
    20  
    2110namespace CHCDemo 
    2211{ 
     12 
     13#if TOIMPLEMENT 
    2314 
    2415#define INVALID_TEST ((unsigned int)-1) 
     
    25932584}  
    25942585 
    2595 } 
    2596  
    25972586#endif 
     2587 
     2588} 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h

    r2751 r2752  
    44#define __BVH_H 
    55 
    6  
    7 #if TOIMPLEMENT 
    8  
    9 #include "Bounds.h" 
    10 #include "PerfTimer.h" 
    11 #include "NV_RenderPredictorRenderAction.h" 
    12 #include "VisibilityPredictor.h" 
    13 #include "HierarchyNode.h" 
    14 #include "FlexibleHeap.h" 
    15  
     6#include "Geometry.h" 
     7//#include "FlexibleHeap.h" 
    168 
    179 
    1810namespace CHCDemo 
    1911{ 
    20  
    2112 
    2213//////// 
    2314// Forward declarations 
    2415 
    25 class Scene; 
    26 class Node; 
     16class SceneGeometry; 
    2717class Camera; 
    28 class Box; 
    29 class BvhLeaf; 
    30 class BvhNode; 
    31 class TriangleBvh; 
    32  
    3318 
    3419 
    3520/** A node in the bv hierarchy. 
    3621*/ 
    37 class BvhNode: public RenderableHierarchyNode, public Heapable 
     22class BvhNode 
    3823{ 
    3924        friend class Bvh; 
     
    5035                void Reset(); 
    5136 
    52  
    5337                /// if the node is visible 
    5438                bool mIsVisible; 
    55                 /// if all the leaves are visible 
    56                 bool mIsFullyVisible; 
    57                  
    58                 /// #pixels this node was visible for the last test 
    59                 int mVisiblePixels;              
    6039                /// #frames this node is assumed to stay visible 
    6140                int mAssumedVisibleFrames; 
    62                 /// #frames this node is assumed to stay visible 
    63                 int mRemainingVisibleFrames; 
    64                  
    65                 /// the frame in which the node was last tested visible 
    66                 int mLastTestedVisibleFrame; 
    6741                /// the frame when this node was last touched during traversal 
    6842                int mLastVisitedFrame; 
    69                 /// frame id when the node turned visible 
    70                 int mTurnedVisibleFrame; 
    71                 /// when was the node last tested 
    72                 int mLastTestedFrame; 
    73  
    7443                /// #times this node was invisible (only valid if the node actually is invisible) 
    7544                int mTimesInvisible; 
    76                 /// #times this node was tested 
    77                 int mTimesTested; 
    78                 /// #times this node was tested 
    79                 int mTimesChangedClassification; 
    80                 /// The ratio of classification changes / tests 
    81                 float mAvgChangedClassification; 
    82                  
    8345                /// if the node is view frustum culled 
    8446                bool mIsFrustumCulled; 
    85  
     47                /// if the node is newly processed with no prior history available 
    8648                bool mIsNew; 
    8749        }; 
     
    9961        /** Returns unique id for this node. 
    10062        */ 
    101         inline int GetId() {return mId;} 
     63        //inline int GetId() {return mId;} 
    10264        /** Depth of this node in the tree. 
    10365        */ 
    104         inline int GetDepth() const {return (int)mDepth;} 
     66        inline int GetDepth() const {return mDepth;} 
    10567        /** Returns parent of this bvh node, NULL if it is root. 
    10668        */ 
     
    10971        */ 
    11072        inline int GetNumLeaves() const {return mNumLeaves;} 
    111         /** Box used for visualization. 
    112         */ 
    113         Box *GetOrCreateVizBox(); 
    11473        /** Reset the status of this node. 
    11574        */ 
    11675        virtual void ResetVisibility(); 
    11776 
    118         virtual int GetType() { return BVH_NODE; } 
     77        virtual int GetType() = 0; //{ return BVH_NODE; } 
    11978 
    12079 
     
    14099        */ 
    141100        inline void SetRemainingVisibleFrames(const int t); 
    142         /** See set. 
    143         */ 
    144         inline int GetRemainingVisibleFrames() const; 
    145101        /** Decrease the time this node is considered visible. 
    146102        */ 
    147         inline void DecRemainingVisibleFrames(); 
    148         /** Returns the frame id when this node was tested 
    149                 visible. 
    150         */ 
    151         inline void SetLastTestedVisibleFrame(const int t); 
    152         /** See set. 
    153         */ 
    154         inline int GetLastTestedVisibleFrame() const; 
     103        inline void DecAssumedVisibleFrames(); 
    155104        /** Increases the #times this node was 
    156105                successfully tested invisible. 
    157106        */ 
    158107        inline void IncTimesInvisible(); 
    159         /** If the subtree induced by this node 
    160                 is fully visible. 
    161         */ 
    162         inline bool IsFullyVisible(); 
    163  
     108         
    164109        inline int GetTimesInvisible() const; 
    165110        inline void SetTimesInvisible(const int t); 
     
    170115        inline int GetLastTestedFrame(); 
    171116        inline void SetLastTestedFrame(const int lastTested); 
    172  
    173         inline void SetVisiblePixels(const int pixels); 
    174         inline int GetVisiblePixels(); 
    175  
    176         inline void IncTimesTested(); 
    177         inline void IncTimesChangedClassficiation(); 
    178  
    179         inline int GetTimesTested(); 
    180         inline int GetTimesChangedClassification(); 
    181117         
    182118        inline bool IsViewFrustumCulled() const; 
     
    196132        */ 
    197133        inline void SetLastRenderedFrame(int lastRenderedFrame); 
    198          
    199          
    200134        /** Does this node contain renderable geometry? 
    201135        */ 
     
    206140 
    207141 
    208         /////////////// 
    209         //-- public stuff 
    210  
    211         /// Visibility measurements for the period this node was visible 
    212         VisibilityMeasurementBuffer mMeasurements; 
     142protected: 
     143 
     144        ///////////// 
     145         
    213146        /// some flags 
    214147        int mFlags; 
    215  
    216         //int mNumFailedTests; 
    217  
    218 protected: 
    219  
    220         /** Marks the subtree induced by this node 
    221                 as fully visible. 
    222         */ 
    223         inline void SetFullyVisible(const bool visible); 
    224  
    225  
    226         ///////////// 
    227  
    228148        /// the depth of this node 
    229149        unsigned char mDepth; 
     
    232152        /// the parent node 
    233153        BvhNode *mParent; 
    234          
    235154        /// stores the visibility related parameters 
    236155        VisibilityInfo mVisibility; 
     
    252171         
    253172        // Indices to first and last triangle in the triangle array 
    254         // assumes the traingle are placed in continuous chunk of memory 
     173        // assumes the triangle are placed in continuous chunk of memory 
    255174        // however this need not be a global array! 
    256175         
     
    264183        int mNumTestNodes; 
    265184        int mIndicesPtr; 
    266  
    267185        /// Area of this node 
    268186        float mArea; 
     
    297215 
    298216 
    299 void BvhNode::SetLastTestedVisibleFrame(const int t)  
    300 {  
    301         mVisibility.mLastTestedVisibleFrame = t;  
    302 } 
    303  
    304  
    305 int BvhNode::GetLastTestedVisibleFrame() const  
    306 {  
    307         return mVisibility.mLastTestedVisibleFrame;  
    308 } 
    309  
    310  
    311217void BvhNode::IncTimesInvisible()  
    312218{  
     
    315221 
    316222 
    317 bool BvhNode::IsFullyVisible()  
    318 {  
    319         return mVisibility.mIsFullyVisible;  
    320 } 
    321  
    322  
    323223int BvhNode::GetTimesInvisible() const  
    324224{  
     
    333233 
    334234 
    335 int BvhNode::GetTurnedVisibleFrame() const  
    336 {  
    337         return mVisibility.mTurnedVisibleFrame;  
    338 } 
    339  
    340  
    341 void BvhNode::SetTurnedVisibleFrame(const int turnedVisibleFrame)  
    342 {  
    343         mVisibility.mTurnedVisibleFrame = turnedVisibleFrame;  
    344 } 
    345  
    346  
    347 int BvhNode::GetLastTestedFrame()  
    348 {  
    349         return mVisibility.mLastTestedFrame;  
    350 } 
    351  
    352  
    353 void BvhNode::SetLastTestedFrame(const int lastTested) 
    354 {  
    355         mVisibility.mLastTestedFrame = lastTested;  
    356 } 
    357  
    358  
    359 void BvhNode::SetVisiblePixels(const int pixels) 
    360 {  
    361         mVisibility.mVisiblePixels = pixels;  
    362 } 
    363  
    364  
    365 int BvhNode::GetVisiblePixels()  
    366 { 
    367         return mVisibility.mVisiblePixels; 
    368 } 
    369  
    370  
    371 void BvhNode::IncTimesTested()  
    372 {  
    373         ++ mVisibility.mTimesTested;  
    374 } 
    375  
    376  
    377 void BvhNode::IncTimesChangedClassficiation()  
    378 {  
    379         ++ mVisibility.mTimesChangedClassification;  
    380 } 
    381  
    382  
    383 int BvhNode::GetTimesTested()  
    384 {  
    385         return mVisibility.mTimesTested;  
    386 } 
    387  
    388  
    389 int BvhNode::GetTimesChangedClassification()  
    390 {  
    391         return mVisibility.mTimesChangedClassification;  
    392 } 
    393  
    394  
    395235bool BvhNode::IsViewFrustumCulled() const  
    396236{  
     
    452292} 
    453293 
    454  
    455 void BvhNode::SetRemainingVisibleFrames(const int t)  
    456 {  
    457         mVisibility.mRemainingVisibleFrames = t;  
    458 } 
    459  
    460  
    461 int BvhNode::GetRemainingVisibleFrames() const  
    462 {  
    463         return mVisibility.mRemainingVisibleFrames; 
    464 } 
    465  
    466  
    467 void BvhNode::DecRemainingVisibleFrames()  
    468 { 
    469         -- mVisibility.mRemainingVisibleFrames;  
    470 } 
    471  
     294void BvhNode::DecAssumedVisibleFrames()  
     295{ 
     296        -- mVisibility.mAssumedVisibleFrames;  
     297} 
    472298 
    473299 
     
    515341public: 
    516342 
    517         BvhLeaf(BvhNode *parent): BvhNode(parent), mTriangleBvh(NULL) 
     343        BvhLeaf(BvhNode *parent): BvhNode(parent) 
    518344        {} 
    519345 
     
    521347 
    522348        virtual bool IsLeaf() { return true; } 
    523 }; 
    524  
    525  
    526 struct NodeGeometry 
    527 { 
    528         virtual AxisAlignedBox3 GetBoundingBox() = 0; 
    529 }; 
    530  
    531  
    532 struct ObjectGeometry 
    533 { 
    534         virtual AxisAlignedBox3 GetBoundingBox() = 0; 
    535 }; 
    536  
    537  
    538 struct TriangleGeometry 
    539 { 
    540         virtual AxisAlignedBox3 GetBoundingBox() = 0; 
    541349}; 
    542350 
     
    608416        /** Returns geometry by reference (faster). 
    609417        */ 
    610         NodeGeometry **GetGeometry(BvhNode *node, int &size); 
     418        SceneGeometry **GetGeometry(BvhNode *node, int &size); 
    611419 
    612420 
     
    636444        /** sets frame dependent values. 
    637445        */ 
    638         void InitFrame(Camera *camera, const int currentFrameId, Viewer *viewer); 
    639         /** this gives the orthogonal distance from the viewpoint to the nearest BBox-Vertex 
     446        void InitFrame(Camera *camera, const int currentFrameId); 
     447        /** this gives the orthogonal distance from the viewpoint to the nearest bounding box vertex 
    640448                note that negative values can appear because culling is done only afterwards 
    641449        */ 
     
    645453        */ 
    646454        void SetMaxDepthForTestingChildren(const int maxDepth); 
    647         /** Resize the visibility buffers of the bvh nodes. 
    648         */ 
    649         void ResizeVisibilityBuffers(const int size); 
    650  
    651          
    652455        /** Pulls up the fully visible classification in the bvh. 
    653456        */ 
     
    681484        void SetAreaRatioThresholdForTestingChildren(const float ratio); 
    682485 
    683         void SetVolRatioThresholdForTestingChildren(const float ratio); 
    684         /** Returns depth of bvh hierarchy. 
    685         */ 
    686         float GetAvgDepth() const; 
    687  
    688486 
    689487        const BvhStats &GetBvhStats() const {return mBvhStats;} 
     
    691489        void SetCollectTighterBoundsWithMaxLevel(bool t); 
    692490 
    693  
    694         ///////////// 
    695         //-- timers 
    696  
    697         mutable PerfTimer timeSetup; 
    698         mutable PerfTimer timeIssueDrawElements; 
    699         mutable PerfTimer timeViewFrustumCulling; 
    700         mutable PerfTimer timeDistance; 
    701491 
    702492        ////////////// 
     
    719509        //////////////////// 
    720510 
    721         /** Constructor taking the geometry and a pointer to the current render action. 
    722         */ 
    723         Bvh(const GeometryVector &geometry,  
    724                 DistanceSortedRenderAction *const renderer); 
     511        /** Constructor loading the bvh from disc 
     512        */ 
     513        Bvh(const std::string &filename); 
    725514        /** protected constructor: do nothing. 
    726515        */ 
    727         Bvh(): mCamera(NULL), mFrameId(-1), mVertices(NULL), mRenderer(NULL) {} 
     516        //Bvh(): mCamera(NULL), mFrameId(-1), mVertices(NULL), mRenderer(NULL) {} 
    728517        /** Destructor. 
    729518        */ 
     
    731520 
    732521 
    733  
    734         //-- sorting functions 
    735  
    736         /** The method of subdividing objects into halves in some axis using spatial median 
    737         */ 
    738         int     SortTrianglesSpatialMedian(BvhLeaf *leaf, const int axis); 
    739         /** The method of subdividing objects into halves in some axis 
    740                 using object median. 
    741         */ 
    742         int     SortTrianglesObjectMedian(BvhLeaf *leaf, const int axis, float &pos); 
    743         /** sort triangles along the axis with respect to the splitting plane  
    744                 given by axis/position return index of the first tiangles belong  
    745                 to the front of the splitting plane. 
    746         */ 
    747         int     SortTriangles(BvhLeaf *leaf, const int axis, const float position); 
    748         /** sort triangles by their area. 
    749         */ 
    750         int SortTrianglesSurfaceArea(BvhLeaf *leaf, const float sa); 
    751  
    752  
    753522        ///////////// 
    754  
    755  
    756         /** Subdivides the current leaf. 
    757         */ 
    758         BvhNode *SubdivideLeaf(BvhLeaf *leaf, const int parentAxis);     
    759         /** select splitting plane using SAH - returns the position of the splitting plane. 
    760         */ 
    761         float SelectPlaneSah(BvhLeaf *leaf, int &axis, float &minCost); 
    762         /** evaluate the SAH cost of a particulkar splitting plane 
    763         */ 
    764         float EvaluateSahCost(BvhLeaf *leaf, const int axis, const float position); 
    765523 
    766524        void ComputeBvhStats(); 
    767525        void PrintBvhStats() const; 
    768526 
    769         /** Update children nodes recursively. 
    770         */ 
    771         void UpdateBoxes(BvhNode *node); 
    772         /** Update box for a leaf node 
    773         */ 
    774         void UpdateLeafBox(BvhLeaf *leaf); 
    775         /** Returns true if termination criteria met. 
    776         */ 
    777         bool TerminationCriteriaMet(BvhLeaf *leaf) const; 
    778         /** Compute unique ids for the bvh nodes. 
    779         */ 
    780         void ComputeIds(); 
    781         /** Helper method that updates the number of leaves in the subtree under 
    782                 this node. 
    783         */ 
    784         void UpdateNumLeaves(BvhNode *node) const; 
    785  
    786527 
    787528        ////////// 
     
    791532 
    792533        int PrepareBoundingBoxesWithDrawArrays(const BvhNodeContainer &nodes); 
    793         void RenderBoundingBoxesWithDrawArrays(const int numNodes); 
     534        void RenderBoundingBoxesWithDrawArrays(int numNodes); 
    794535 
    795536        int RenderBoundingBoxesImmediate(const BvhNodeContainer &nodes); 
     
    797538                and restarts the strip only if wished. 
    798539        */ 
    799         void RenderBoundingBoxImmediate(const BoundingBox &box, const bool restartStrip); 
     540        void RenderBoundingBoxImmediate(const AxisAlignedBox3 &box, bool restartStrip); 
    800541        /** Create the indices that each node needs to use vbo rendering. 
    801542        */ 
     
    818559        int PostProcessLeaves(BvhLeafContainer &leaves); 
    819560 
    820         bool CreateTighterBoundsForLeaf(BvhLeaf *leaf, Point3f *triangles, const int triangleCount); 
    821  
    822         Point3f *CollectTriangles(BvhLeaf *leaf, int &triangleCount); 
     561        //bool CreateTighterBoundsForLeaf(BvhLeaf *leaf, Point3f *triangles, int triangleCount); 
     562 
     563        ///Point3f *CollectTriangles(BvhLeaf *leaf, int &triangleCount); 
    823564 
    824565        int     IsWithinViewFrustumLocal(BvhNode *node); 
    825566 
    826         int     IsWithinViewFrustum(const BoundingBox &box, const int planeMask, const int preferredPlane); 
    827         /** Compute screen space projection of a bounding box. 
    828         */ 
    829         float ComputeScreenSpaceProjection(const BoundingBox &box) const; 
    830  
    831         float GetMinSquareDistance(const BoundingBox &box) const; 
    832         /** Computes the area of the triangles in a leaf. 
    833         */ 
    834         float ComputeGeometryArea(BvhLeaf *leaf, Point3f *triangles, const int triangleCount) const; 
    835  
    836  
     567        int     IsWithinViewFrustum(const AxisAlignedBox3 &box, int planeMask, int preferredPlane); 
     568         
     569        float GetMinSquareDistance(const AxisAlignedBox3 &box) const; 
     570         
    837571         
    838572        //////////////////////// 
     
    841575        BvhNode *mRoot; 
    842576        /// pointers to the geometry associated with this node 
    843         NodeGeometry **mGeometry; 
    844         /// #of entities of geometry 
     577        SceneGeometry **mGeometry; 
     578        /// #of entities 
    845579        size_t mGeometrySize; 
    846580 
    847  
    848         ///////// 
    849         //-- termination criteria 
    850  
    851         int mMaxGeometry; 
    852         int mMaxTriangles; 
    853         int mSplitType; 
    854         int mNumNodes; 
    855         int mMaxDepth; 
    856         float mMinArea; 
    857581 
    858582        //////////////// 
     
    868592        int mFrameId; 
    869593        /// a vertex array used if working with indexed arrays (without vbo) 
    870         Point3f *mVertices; 
     594        //Point3f *mVertices; 
    871595        /// indices used for draw array rendering 
    872596        unsigned int *mIndices; 
     
    880604        float mVolRatioThreshold; 
    881605 
    882         /// pointer to the renderaction 
    883         DistanceSortedRenderAction *const mRenderer; 
    884  
    885606        BvhStats mBvhStats; 
    886607 
    887         HierarchyNodeContainer mTestNodes; 
     608        //HierarchyNodeContainer mTestNodes; 
    888609         
    889610        unsigned int *mTestIndices; 
    890  
    891611        /// a pointer to the end of the indices array 
    892612        int mCurrentIndicesPtr; 
     
    894614        float mScale; 
    895615 
    896         float mAvgDepth; 
    897  
    898         Vector3f mNearPlane; 
     616        Vector3 mNearPlane; 
    899617        float mNearPlaneD; 
     618        int mNumNodes; 
    900619}; 
    901620 
    902621} 
    903622 
    904 #endif 
    905623#endif // __BVH_H 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.h

    r2751 r2752  
    11#ifndef GEOMETRY_H 
    22#define GEOMETRY_H 
     3 
     4#include "common.h" 
     5#include "AxisAlignedBox3.h" 
     6 
    37 
    48 
    59namespace CHCDemo  
    610{ 
     11 
     12class Material; 
     13 
     14 
    715 
    816/** Represents drawable geometry consisting of triangles 
     
    1927        AxisAlignedBox3 mBoundingBox; 
    2028        TriangleContainer mTriangles; 
    21 } 
     29}; 
    2230 
    2331 
     
    6573 
    6674} 
     75 
    6776#endif // GEOMETRY_H 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Matrix4x4.cpp

    r2751 r2752  
    615615} 
    616616 
    617 // Rotate a direction vector... 
    618 Vector3 
    619 PlaneRotate(const Matrix4x4& tform, const Vector3& p) 
     617 
     618Vector3 PlaneRotate(const Matrix4x4& tform, const Vector3& p) 
    620619{ 
    621620        // I sure hope that matrix is invertible... 
     
    626625 
    627626// Transform a normal 
    628 Vector3 
    629 TransformNormal(const Matrix4x4& tform, const Vector3& n) 
     627Vector3 TransformNormal(const Matrix4x4& tform, const Vector3& n) 
    630628{ 
    631629        Matrix4x4 use = NormalTransformMatrix(tform); 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Vector3.h

    r2751 r2752  
    6767                return (const float*) this;  
    6868        } 
    69  
    7069 
    7170        const float &operator[] (const int inx) const  
     
    8180        } 
    8281 
    83          
    8482        void SetValue(float a)  
    8583        {  
     
    9088        */ 
    9189        int DrivingAxis(void) const; 
    92  
    9390        /** returns the axis, where the std::vector has the smallest value 
    9491        */ 
     
    10097                return (x > y) ? ( (x > z) ? x : z) : ( (y > z) ? y : z); 
    10198        } 
    102          
    10399        /** Returns copy of this vector where all components are positiv. 
    104100        */ 
     
    107103                return Vector3(fabs(x), fabs(y), fabs(z)); 
    108104        } 
    109  
    110         // normalizes the std::vector of unit size corresponding to given std::vector 
     105        /** normalizes the std::vector of unit size corresponding to given std::vector 
     106        */ 
    111107        inline void Normalize(); 
    112  
    113108        /** Returns false if this std::vector has a nan component. 
    114109        */ 
    115110        bool CheckValidity() const; 
    116  
    117         /** 
    118         ===> Using ArbitraryNormal() for constructing coord systems  
    119         ===> is obsoleted by RightHandedBase() method (<JK> 12/20/03).    
    120  
    121         Return an arbitrary normal to `v'. 
    122         In fact it tries v x (0,0,1) an if the result is too small, 
    123         it definitely does v x (0,1,0). It will always work for 
    124         non-degenareted std::vector and is much faster than to use 
    125         TangentVectors. 
    126  
    127         @param v(in) The std::vector we want to find normal for. 
    128         @return The normal std::vector to v. 
    129         */ 
    130         friend inline Vector3 ArbitraryNormal(const Vector3 &v);  
    131  
    132111        /** 
    133112        Find a right handed coordinate system with (*this) being 
     
    152131        */ 
    153132        void RightHandedBase(Vector3& U, Vector3& V) const; 
     133         
     134         
     135        // Unary operators 
     136 
     137        Vector3 operator+ () const; 
     138        Vector3 operator- () const; 
     139 
     140        // Assignment operators 
     141         
     142        Vector3& operator+= (const Vector3 &A); 
     143        Vector3& operator-= (const Vector3 &A); 
     144        Vector3& operator*= (const Vector3 &A); 
     145        Vector3& operator*= (float A); 
     146        Vector3& operator/= (float A); 
     147 
     148 
     149        ////////// 
     150        //-- friends 
     151         
     152        /** 
     153        ===> Using ArbitraryNormal() for constructing coord systems  
     154        ===> is obsoleted by RightHandedBase() method (<JK> 12/20/03).    
     155 
     156        Return an arbitrary normal to `v'. 
     157        In fact it tries v x (0,0,1) an if the result is too small, 
     158        it definitely does v x (0,1,0). It will always work for 
     159        non-degenareted std::vector and is much faster than to use 
     160        TangentVectors. 
     161 
     162        @param v(in) The std::vector we want to find normal for. 
     163        @return The normal std::vector to v. 
     164        */ 
     165        friend inline Vector3 ArbitraryNormal(const Vector3 &v);  
    154166 
    155167        /// Transforms a std::vector to the global coordinate frame. 
     
    162174        */ 
    163175        friend inline Vector3 ToGlobalFrame(const Vector3& loc, 
    164                 const Vector3& U, 
    165                 const Vector3& V, 
    166                 const Vector3& N); 
     176                                                const Vector3& U, 
     177                                                                                const Vector3& V, 
     178                                                                                const Vector3& N); 
    167179 
    168180        /// Transforms a std::vector to a local coordinate frame. 
     
    175187        */ 
    176188        friend inline Vector3 ToLocalFrame(const Vector3& loc, 
    177                 const Vector3& U, 
    178                 const Vector3& V, 
    179                 const Vector3& N); 
     189                                           const Vector3& U, 
     190                                                                           const Vector3& V, 
     191                                                                           const Vector3& N); 
    180192 
    181193        /// the magnitude=size of the std::vector 
     
    187199        /// SqrMagnitude(v1-v2) 
    188200        friend inline float SqrDistance(const Vector3 &v1, const Vector3 &v2); 
    189  
    190         // creates the std::vector of unit size corresponding to given std::vector 
     201        /// creates the std::vector of unit size corresponding to given std::vector 
    191202        friend inline Vector3 Normalize(const Vector3 &A); 
    192  
    193         // Rotate a normal std::vector. 
     203        /// // Rotate a direction vector 
    194204        friend Vector3 PlaneRotate(const Matrix4x4 &, const Vector3 &); 
    195205 
     
    209219        // to the vectors `N','D', and `V'. Then 'N', 'U', and 'V' create 
    210220        // the orthonormal base in space R3. 
    211         friend void TangentVectors(Vector3 &U,  
    212                                        Vector3 &V, // output 
     221        friend void TangentVectors(Vector3 &U, Vector3 &V, // output 
    213222                                                           const Vector3 &normal, // input 
    214223                                                           const Vector3 &dirIncoming); 
    215224 
    216         // Unary operators 
    217         Vector3 operator+ () const; 
    218         Vector3 operator- () const; 
    219  
    220         // Assignment operators 
    221         Vector3& operator+= (const Vector3 &A); 
    222         Vector3& operator-= (const Vector3 &A); 
    223         Vector3& operator*= (const Vector3 &A); 
    224         Vector3& operator*= (float A); 
    225         Vector3& operator/= (float A); 
    226225 
    227226        // Binary operators 
     227         
    228228        friend inline Vector3 operator+ (const Vector3 &A, const Vector3 &B); 
    229229        friend inline Vector3 operator- (const Vector3 &A, const Vector3 &B); 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/common.h

    r2751 r2752  
    2020 
    2121struct Triangle3; 
    22    
     22class BvhNode; 
     23class BvhLeaf; 
     24 
     25 
    2326#if defined(_MSC_VER) 
    2427// use perftimer only on msvc 
     
    454457 
    455458 
     459 
     460/////////// 
     461//-- typedefs 
     462 
     463typedef std::vector<BvhNode *> BvhNodeContainer; 
     464typedef std::vector<BvhLeaf *> BvhLeafContainer; 
    456465typedef std::vector<Triangle3> TriangleContainer; 
    457466 
    458 } 
    459  
    460 #endif 
    461  
    462  
    463  
    464  
    465  
    466  
    467  
    468  
     467 
     468} 
     469 
     470#endif 
     471 
     472 
     473 
     474 
     475 
     476 
     477 
     478 
Note: See TracChangeset for help on using the changeset viewer.