murarinayak / papervision3d

Automatically exported from code.google.com/p/papervision3d
0 stars 0 forks source link

Optimization #240

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. In many loops uint is used. On of the spots
public function hitTestPoint2D(point:Point):RenderHitData
        {
            if(interactive){
                var rli:RenderableListItem;
                var rhd:RenderHitData = new RenderHitData();
                var rc:IRenderListItem;
                for(var i:uint = lastRenderList.length; rc = lastRenderList[--i]; )
                {
                    if(rc is RenderableListItem)
                    {
                        rli = rc as RenderableListItem;
                        rhd = rli.hitTestPoint2D(point, rhd);

                        if(rhd.hasHit)
                        {               
                            return rhd;
                        }
                    }
                }
            }

            return new RenderHitData();
        }
 In 1000000 loops(faces) time difference matters. Use "int" instead,it is
the fastest.

2. for(int i=0; i<arr.len;i++) makes process to make lookup every loop.
put var len:int=arr.len; instead and use len in loop.
3. don't use arrays but use vectors(typed one) vector.<RenderListItem>
4. rc = lastRenderList[--i] as RenderListItem; If you must using arrays cast 

Regards
Alex

Original issue reported on code.google.com by winxa...@gmail.com on 20 Nov 2009 at 6:36