Ignore:
Timestamp:
03/12/07 18:30:52 (17 years ago)
Author:
mattausch
Message:

worked on optimization. warning: not tested yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2233 r2237  
    3232#define VISUALIZE_SPLIT 0 
    3333#define USE_FIXEDPOINT_T 0 
     34#define HACK_PERFORMANCE 1 
     35 
    3436 
    3537///////////// 
     
    513515        ////////////////////////////////////////////// 
    514516        // bounding box of view space includes all visibility events 
     517 
    515518        mBoundingBox.Initialize(); 
    516519        VssRayContainer::const_iterator rit, rit_end = rays.end(); 
     
    802805        VspLeaf *leaf = static_cast<VspLeaf *>(splitCandidate.mParentData.mNode); 
    803806 
     807                ////////////// 
     808        //-- compute global decrease in render cost 
     809 
     810        const AxisAlignedPlane candidatePlane = splitCandidate.mSplitPlane; 
     811 
     812        RayInfoContainer::const_iterator rit, rit_end = splitCandidate.mParentData.mRays->end(); 
     813 
     814        float frontRenderCost = 0, backRenderCost = 0, totalRenderCost = 0; 
     815        int  frontSize = 0, backSize = 0, totalSize = 0; 
     816 
     817        Intersectable::NewMail(3); 
     818        KdLeaf::NewMail(3); 
     819 
     820        for (rit = splitCandidate.mParentData.mRays->begin(); rit != rit_end; ++ rit) 
     821        { 
     822                RayInfo rayInf = *rit; 
     823 
     824                float t; 
     825                 
     826                // classify ray 
     827                const int cf = rayInf.ComputeRayIntersection(candidatePlane.mAxis,  
     828                                                                                                         candidatePlane.mPosition,  
     829                                                                                                         t); 
     830 
     831                VssRay *ray = rayInf.mRay; 
     832#if HACK_PERFORMANCE 
     833                Intersectable *obj = (*ray).mTerminationObject; 
     834 
     835                BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
     836 
     837                // evaluate contribution of ray endpoint to front  
     838                // and back pvs with respect to the classification 
     839                UpdateContributionsToPvs(leaf, cf,  
     840                                                                 frontRenderCost, backRenderCost, totalRenderCost), 
     841                                                                 frontSize, backSize, totalSize; 
     842 
     843#if COUNT_ORIGIN_OBJECTS 
     844 
     845                obj = (*ray).mOriginObject; 
     846 
     847                if (obj) 
     848                { 
     849                        leaf = mBvHierarchy->GetLeaf(obj); 
     850 
     851                        UpdateContributionsToPvs(leaf, cf,  
     852                                                                         frontRenderCost, backRenderCost, totalRenderCost, 
     853                                                                         frontSize, backSize, totalSize); 
     854                } 
     855#endif 
     856 
     857#else 
     858                cerr << "TODO classify" << endl; 
     859#endif 
     860        } 
     861 
    804862        ///////////// 
    805863        // avg ray contri 
    806864 
    807         const int pvs = EvalPvsEntriesSize(*splitCandidate.mParentData.mRays); 
    808  
    809         const float avgRayContri = (float)pvs /  
     865        const float avgRayContri = (float)totalSize /  
    810866                ((float)splitCandidate.mParentData.mRays->size() + Limits::Small); 
    811867 
     
    813869 
    814870        const float avgRaysPerObject =  
    815                 (float)splitCandidate.mParentData.mRays->size() / ((float)pvs + Limits::Small); 
     871                (float)splitCandidate.mParentData.mRays->size() / ((float)totalSize + Limits::Small); 
    816872 
    817873        splitCandidate.SetAvgRayContribution(avgRayContri); 
    818874        splitCandidate.SetAvgRaysPerObject(avgRaysPerObject); 
    819875 
    820         // compute global decrease in render cost 
     876 
    821877        float oldRenderCost; 
    822         const float renderCostDecr = EvalRenderCostDecrease(splitCandidate, oldRenderCost); 
     878        const float renderCostDecr = EvalRenderCostDecrease(splitCandidate, oldRenderCost, 
     879                                                                                                                 totalRenderCost, frontRenderCost, backRenderCost); 
    823880        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    824881 
    825882        // the increase in pvs entries num induced by this split 
    826         const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate); 
     883        const int pvsEntriesIncr = EvalPvsEntriesIncr(splitCandidate, totalSize, frontSize, backSize); 
    827884        splitCandidate.SetPvsEntriesIncr(pvsEntriesIncr); 
    828885 
     
    844901 
    845902 
    846 int VspTree::EvalPvsEntriesIncr(VspSubdivisionCandidate &splitCandidate) const 
    847 { 
    848         float oldPvsSize = 0; 
    849         float fPvsSize = 0; 
    850         float bPvsSize = 0; 
    851          
    852         const AxisAlignedPlane candidatePlane = splitCandidate.mSplitPlane; 
    853          
    854         Intersectable::NewMail(3); 
    855         KdLeaf::NewMail(3); 
    856  
     903int VspTree::EvalPvsEntriesIncr(VspSubdivisionCandidate &splitCandidate, 
     904                                                                const float oldPvsSize, 
     905                                                                const float fPvsSize, 
     906                                                                const float bPvsSize) const 
     907{ 
     908         
    857909        RayInfoContainer::const_iterator rit, rit_end = splitCandidate.mParentData.mRays->end(); 
    858  
    859     // this is the main ray classification loop! 
    860         for(rit = splitCandidate.mParentData.mRays->begin(); rit != rit_end; ++ rit) 
    861         { 
    862                 VssRay *ray = (*rit).mRay; 
    863                 RayInfo rayInf = *rit; 
    864                  
    865                 float t; 
    866                 // classify ray 
    867                 const int cf =  rayInf.ComputeRayIntersection(candidatePlane.mAxis,  
    868                                                                                                           candidatePlane.mPosition, t); 
    869  
    870                 UpdatePvsEntriesContribution(*ray, true, cf, fPvsSize, bPvsSize, oldPvsSize); 
    871 #if COUNT_ORIGIN_OBJECTS 
    872                 UpdatePvsEntriesContribution(*ray, false, cf, fPvsSize, bPvsSize, oldPvsSize); 
    873 #endif 
    874         } 
    875910 
    876911        const float oldPvsRatio = (splitCandidate.mParentData.mPvs > 0) ?  
     
    11881223 
    11891224 
    1190 int VspTree::EvalMaxEventContribution(KdLeaf *leaf) const 
    1191 { 
    1192         int pvs = 0; 
     1225float VspTree::EvalMaxEventContribution(KdLeaf *leaf) const 
     1226{ 
     1227        float pvs = 0; 
    11931228 
    11941229        // leaf falls out of right pvs 
    11951230        if (-- leaf->mCounter == 0) 
    11961231        { 
    1197                 pvs -= ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 
     1232                pvs -= ((float)leaf->mObjects.size() - (float)leaf->mMultipleObjects.size()); 
    11981233        } 
    11991234 
     
    12171252 
    12181253 
    1219 int VspTree::EvalMinEventContribution(KdLeaf *leaf) const 
     1254float VspTree::EvalMinEventContribution(KdLeaf *leaf) const 
    12201255{ 
    12211256        if (leaf->Mailed()) 
     
    12251260 
    12261261        // add objects without those which are part of several kd leaves 
    1227         int pvs = ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 
     1262        float pvs = ((float)leaf->mObjects.size() - (float)leaf->mMultipleObjects.size()); 
    12281263 
    12291264        // separately handle objects which are part of several kd leaves  
     
    16441679 
    16451680float VspTree::EvalRenderCostDecrease(VspSubdivisionCandidate &sc, 
    1646                                                                           float &normalizedOldRenderCost) const 
    1647 { 
    1648         float pvsFront = 0; 
    1649         float pvsBack = 0; 
    1650         float totalPvs = 0; 
    1651  
     1681                                                                          float &normalizedOldRenderCost, 
     1682                                                                          const float totalPvs, 
     1683                                                                          const float pvsFront, 
     1684                                                                          const float pvsBack) const 
     1685{ 
    16521686        const float viewSpaceVol = mBoundingBox.GetVolume(); 
    16531687        const VspTraversalData &tData = sc.mParentData; 
     
    16631697        Intersectable::NewMail(3); 
    16641698        KdLeaf::NewMail(3); 
    1665  
    1666         RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 
    1667  
    1668         for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 
    1669         { 
    1670                 RayInfo rayInf = *rit; 
    1671  
    1672                 float t; 
    1673                  
    1674                 // classify ray 
    1675                 const int cf = rayInf.ComputeRayIntersection(candidatePlane.mAxis,  
    1676                                                                                                          candidatePlane.mPosition,  
    1677                                                                                                          t); 
    1678  
    1679                 VssRay *ray = rayInf.mRay; 
    1680  
    1681                 // evaluate contribution of ray endpoint to front  
    1682                 // and back pvs with respect to the classification 
    1683                 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 
    1684  
    1685 #if COUNT_ORIGIN_OBJECTS 
    1686                 UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 
    1687 #endif 
    1688         } 
    16891699     
    16901700        AxisAlignedBox3 frontBox; 
     
    18021812        if (!obj) return; 
    18031813 
    1804         const float renderCost = mViewCellsManager->EvalRenderCost(obj); 
     1814        const float renderCost = ViewCellsManager::EvalRenderCost(obj); 
    18051815 
    18061816        // object in none of the pvss => new object 
     
    18811891                        backPvs += renderCost; 
    18821892                 
     1893                        // already in front pvs => in both pvss 
     1894                        if (leaf->Mailed()) 
     1895                                leaf->Mail(2); 
     1896                        else 
     1897                                leaf->Mail(1); 
     1898                } 
     1899        } 
     1900} 
     1901 
     1902 
     1903void VspTree::UpdateContributionsToPvs(BvhLeaf *leaf, 
     1904                                                                           const int cf, 
     1905                                                                           float &frontPvs, 
     1906                                                                           float &backPvs, 
     1907                                                                           float &totalPvs, 
     1908                                                                           int &frontSize, 
     1909                                                                           int &backSize, 
     1910                                                                           int &totalSize) const 
     1911{ 
     1912        const float renderCost = mBvHierarchy->EvalAbsCost(leaf->mObjects); 
     1913         
     1914        // leaf in no pvs => new 
     1915        if (!leaf->Mailed() && !leaf->Mailed(1) && !leaf->Mailed(2)) 
     1916        { 
     1917                totalPvs += renderCost; 
     1918                ++ totalSize; 
     1919        } 
     1920 
     1921        if (cf >= 0) // front pvs 
     1922        { 
     1923                if (!leaf->Mailed() && !leaf->Mailed(2)) 
     1924                { 
     1925                        frontPvs += renderCost; 
     1926                        ++ frontSize; 
     1927 
     1928                        // already in back pvs => in both pvss 
     1929                        if (leaf->Mailed(1)) 
     1930                                leaf->Mail(2); 
     1931                        else 
     1932                                leaf->Mail(); 
     1933                } 
     1934        } 
     1935 
     1936        if (cf <= 0) // back pvs 
     1937        { 
     1938                if (!leaf->Mailed(1) && !leaf->Mailed(2)) 
     1939                { 
     1940                        backPvs += renderCost; 
     1941                        ++ backSize; 
     1942 
    18831943                        // already in front pvs => in both pvss 
    18841944                        if (leaf->Mailed()) 
     
    23792439 
    23802440{ 
    2381          
     2441 
    23822442#if HACK_PERFORMANCE 
    2383          
    2384         BvhLeaf *bvhleaf = mBvHierarchy->GetLeaf(mTerminationObject); 
     2443        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
     2444 
     2445        if (!obj) return 0; 
     2446        BvhLeaf *bvhleaf = mBvHierarchy->GetLeaf(obj); 
    23852447 
    23862448        if (!bvhleaf->Mailed()) 
     
    23892451                return 1; 
    23902452        } 
     2453 
    23912454#else 
     2455 
    23922456        Intersectable *obj;  
    2393         Vector3 pt; 
     2457        static Vector3 pt; 
    23942458        KdNode *node; 
    23952459 
    23962460        ray.GetSampleData(isTermination, pt, &obj, &node); 
    2397  
     2461         
    23982462        if (!obj) return 0; 
    23992463 
     
    29613025        Intersectable::NewMail(); 
    29623026 
     3027        //////////////// 
    29633028        //-- store rays and objects 
     3029         
     3030        VssRay *lastVssRay = NULL; 
     3031 
    29643032        for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
    29653033        { 
    29663034                VssRay *ray = *rit; 
    2967                 float minT, maxT; 
    2968                 static Ray hray; 
    2969  
    2970                 hray.Init(*ray); 
     3035 
     3036                // filter out double rays (last ray the same as this ray 
     3037                if (!lastVssRay || 
     3038                        !(ray->mOrigin == lastVssRay->mTermination) || 
     3039                        !(ray->mTermination == lastVssRay->mOrigin))  
     3040                { 
     3041                        lastVssRay = ray; 
     3042 
     3043                        float minT, maxT; 
     3044                        static Ray hray; 
     3045 
     3046                        hray.Init(*ray); 
    29713047                 
    2972                 // TODO: not very efficient to implictly cast between rays types 
    2973                 if (GetBoundingBox().GetRaySegment(hray, minT, maxT)) 
    2974                 { 
    2975                         float len = ray->Length(); 
    2976  
    2977                         if (!len) 
    2978                                 len = Limits::Small; 
    2979  
    2980                         rays.push_back(RayInfo(ray, minT / len, maxT / len)); 
     3048                        // TODO: not very efficient to implictly cast between rays types 
     3049                        if (GetBoundingBox().GetRaySegment(hray, minT, maxT)) 
     3050                        { 
     3051                                const float len = ray->Length(); 
     3052 
     3053                                if (len) // ray not degenerate  
     3054                                {       //len = Limits::Small; 
     3055                                        rays.push_back(RayInfo(ray, minT / len, maxT / len)); 
     3056                                } 
     3057                        } 
     3058                } 
     3059                else 
     3060                { 
     3061                        // store object only for one ray 
     3062                        lastVssRay->mOriginObject = ray->mTerminationObject; 
    29813063                } 
    29823064        } 
     
    30863168#if HACK_PERFORMANCE 
    30873169 
     3170        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
     3171 
     3172        if (!obj) return; 
     3173 
     3174        BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
     3175 
    30883176        SubdivisionCandidate *candidate; 
    3089  
    3090         BvhLeaf *leaf = mBvHierarchy->GetLeaf(ray.mTerminationObject); 
    30913177 
    30923178        if (!leaf->Mailed()) 
     
    31643250        RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 
    31653251 
    3166         // add all kd nodes seen by the rays 
     3252        // add all nodes seen by the rays 
    31673253        for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 
    31683254        { 
     
    31703256                 
    31713257                CollectDirtyCandidate(*ray, true, dirtyList, onlyUnmailed); 
     3258 
     3259#if COUNT_ORIGIN_OBJECTS 
    31723260        CollectDirtyCandidate(*ray, false, dirtyList, onlyUnmailed); 
    3173         } 
    3174 } 
    3175  
    3176  
    3177 int VspTree::EvalMaxEventContribution(const VssRay &ray,  
     3261#endif 
     3262        } 
     3263} 
     3264 
     3265 
     3266float VspTree::EvalMaxEventContribution(const VssRay &ray,  
    31783267                                                                          const bool isTermination) const 
    31793268{ 
    3180         int pvs = 0; 
    3181  
    31823269#if HACK_PERFORMANCE 
    31833270 
    3184         BvhLeaf *leaf = mBvHierarchy->GetLeaf(ray.mTerminationObject); 
     3271        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
     3272 
     3273        if (!obj) return 0.0f; 
     3274 
     3275        BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
    31853276                         
    31863277        // simple render cost evaluation 
    31873278        if (-- leaf->mCounter == 0) 
    3188                 //pvs += (int)leaf->mObjects.size(); 
    3189                 pvs += mBvHierarchy::EvalAbsCost((int)leaf->mObjects.size()); 
    3190  
     3279                return BvHierarchy::EvalAbsCost(leaf->mObjects); 
     3280        else 
     3281                return 0.0f; 
    31913282#else 
    31923283 
     
    31973288        ray.GetSampleData(isTermination, pt, &obj, &node); 
    31983289 
    3199         if (!obj) return 0; 
     3290        if (!obj) return 0.0f; 
     3291 
     3292        float pvs = 0.0f; 
    32003293 
    32013294        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
     
    32213314                        // simple render cost evaluation 
    32223315                        if (-- leaf->mCounter == 0) 
    3223                                 pvs += (int)leaf->mObjects.size(); 
    3224                                 //pvs += (int)BvHierarchy::EvalAbsCost(leaf->mObjects); 
     3316                                //pvs += (int)leaf->mObjects.size(); 
     3317                                pvs += BvHierarchy::EvalAbsCost(leaf->mObjects); 
    32253318                        break; 
    32263319                } 
     
    32283321                break; 
    32293322        } 
     3323        return pvs; 
     3324 
    32303325#endif 
    3231         return pvs; 
    32323326} 
    32333327 
     
    32353329float VspTree::PrepareHeuristics(const VssRay &ray, const bool isTermination) 
    32363330{ 
     3331         
     3332#if HACK_PERFORMANCE 
     3333         
     3334        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
     3335 
     3336        if (!obj) return 0.0f; 
     3337 
     3338        BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
     3339 
     3340        if (!leaf->Mailed()) 
     3341        { 
     3342                leaf->Mail(); 
     3343                leaf->mCounter = 1; 
     3344                return BvHierarchy::EvalAbsCost(leaf->mObjects); 
     3345        } 
     3346        else 
     3347        { 
     3348                ++ leaf->mCounter;       
     3349                return 0.0f; 
     3350        } 
     3351 
     3352#else 
     3353 
    32373354        float pvsSize = 0; 
    3238          
    3239 #if HACK_PERFORMANCE 
    3240         BvhLeaf *leaf = mBvHierarchy->GetLeaf(ray.mTerminationObject); 
    3241  
    3242         if (!leaf->Mailed()) 
    3243         { 
    3244                 leaf->Mail(); 
    3245                 leaf->mCounter = 0; 
    3246                 pvsSize += (int)leaf->mObjects.size(); 
    3247         } 
    3248  
    3249         ++ leaf->mCounter;       
    3250  
    3251 #else 
    3252          
     3355 
    32533356        Intersectable *obj; 
    32543357        Vector3 pt; 
     
    32573360        ray.GetSampleData(isTermination, pt, &obj, &node); 
    32583361 
    3259         if (!obj) return 0; 
     3362        if (!obj) return 0.0f; 
    32603363 
    32613364        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
     
    32873390                                leaf->Mail(); 
    32883391                                leaf->mCounter = 0; 
    3289                                 pvsSize += (int)leaf->mObjects.size(); 
     3392                                pvsSize += BvHierarchy::EvalAbsCost(leaf->mObjects); 
    32903393                        } 
    32913394 
     
    32963399                break; 
    32973400        } 
     3401        return pvsSize; 
    32983402#endif 
    3299         return pvsSize; 
    3300 } 
    3301  
    3302  
    3303 int VspTree::EvalMinEventContribution(const VssRay &ray,  
    3304                                                                           const bool isTermination) const 
     3403         
     3404} 
     3405 
     3406 
     3407float VspTree::EvalMinEventContribution(const VssRay &ray,  
     3408                                                                                const bool isTermination) const 
    33053409{ 
    33063410#if HACK_PERFORMANCE 
    33073411 
    3308         BvhLeaf *leaf = mBvHierarchy->GetLeaf(ray.mTerminationObject); 
     3412        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
     3413 
     3414        if (!obj) return 0.0f; 
     3415 
     3416        BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
    33093417         
    33103418        if (!leaf->Mailed()) 
    33113419        { 
    33123420                leaf->Mail(); 
    3313                 pvs += (int)leaf->mObjects.size(); 
    3314         } 
    3315  
     3421                return BvHierarchy::EvalAbsCost(leaf->mObjects); 
     3422        } 
     3423        else 
     3424        { 
     3425                return 0.0f; 
     3426        } 
    33163427#else 
    33173428 
    33183429        Intersectable *obj; 
    3319         Vector3 pt; 
     3430        static Vector3 pt; 
    33203431        KdNode *node; 
    33213432 
     
    33243435        if (!obj) return 0; 
    33253436 
    3326         int pvs = 0; 
     3437        float pvs = 0.0f; 
    33273438 
    33283439        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
     
    33503461                        { 
    33513462                                leaf->Mail(); 
    3352                                 pvs += (int)leaf->mObjects.size(); 
     3463                                pvs += BvHierarchy->EvalAbsCost(leaf->mObjects); 
    33533464                        } 
    33543465                        break; 
     
    33573468                break; 
    33583469        } 
     3470        return pvs; 
     3471 
    33593472#endif 
    3360         return pvs; 
    33613473} 
    33623474 
     
    33773489 
    33783490        Intersectable *obj; 
    3379         Vector3 pt; 
     3491        static Vector3 pt; 
    33803492        KdNode *node; 
    33813493 
     
    34213533        UpdateContributionsToPvs(leaf, cf, pvsFront, pvsBack, totalPvs, true); 
    34223534 
    3423  
    34243535#else 
    34253536 
    34263537        Intersectable *obj; 
    3427         Vector3 pt; 
     3538        static Vector3 pt; 
    34283539        KdNode *node; 
    34293540 
     
    34433554                } 
    34443555        default: 
    3445                 UpdateContributionsToPvs(obj, cf, pvsFront, pvsBack, totalPvs);  
    3446                 break; 
     3556                { 
     3557                        UpdateContributionsToPvs(obj, cf, pvsFront, pvsBack, totalPvs);  
     3558                        break; 
     3559                } 
    34473560        } 
    34483561#endif 
     
    34503563 
    34513564 
    3452 int VspTree::EvalContributionToPvs(const VssRay &ray, const bool isTermination) const 
     3565float VspTree::EvalContributionToPvs(const VssRay &ray, const bool isTermination) const 
    34533566{ 
    34543567 
    34553568#if HACK_PERFORMANCE 
    3456         int pvs = 0; 
    3457  
    3458         BvhLeaf *bvhleaf = mBvHierarchy->GetLeaf(ray.mTerminationObject); 
    3459  
    3460         if (!bvhleaf->Mailed()) 
    3461         { 
    3462                 bvhleaf->Mail(); 
    3463                 pvs += (int)bvhleaf->mObjects.size(); 
     3569 
     3570        Intersectable *obj = isTermination ? ray.mTerminationObject : ray.mOriginObject;  
     3571 
     3572        if (!obj) return 0; 
     3573 
     3574        BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 
     3575 
     3576        if (!leaf->Mailed()) 
     3577        { 
     3578                leaf->Mail(); 
     3579                return BvHierarchy::EvalAbsCost(leaf->mObjects); 
     3580        } 
     3581        else 
     3582        { 
     3583                return 0.0f; 
    34643584        } 
    34653585 
    34663586#else 
    3467                  
     3587         
    34683588        Intersectable *obj;  
    3469         Vector3 pt; 
     3589        static Vector3 pt; 
    34703590        KdNode *node; 
    34713591 
     
    34743594        if (!obj) return 0; 
    34753595 
    3476         int pvs = 0; 
     3596        float pvs = 0.0f; 
    34773597 
    34783598        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
     
    35003620                        { 
    35013621                                bvhleaf->Mail(); 
    3502                                 pvs += (int)bvhleaf->mObjects.size(); 
     3622                                pvs += BvHierarchy::EvalAbsCost(bvhleaf->mObjects); 
    35033623                        } 
    35043624                        break; 
     
    35073627                break; 
    35083628        } 
     3629        return pvs; 
     3630 
    35093631#endif 
    3510         return pvs; 
    3511 } 
    3512  
    3513  
    3514 int VspTree::EvalContributionToPvs(KdLeaf *leaf) const 
     3632} 
     3633 
     3634 
     3635float VspTree::EvalContributionToPvs(KdLeaf *leaf) const 
    35153636{ 
    35163637        if (leaf->Mailed()) // leaf already mailed 
     
    35203641 
    35213642        // this is the pvs which is uniquely part of this kd leaf 
    3522         int pvs = (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
     3643        float pvs = (float)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    35233644 
    35243645        ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
Note: See TracChangeset for help on using the changeset viewer.