Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

27. May 2012, 04:11:15 am
Xith3D CommunityXith3D InternalsDeveloper discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)Slow StaticTransform
Pages: [1]
Print
Author Topic: Slow StaticTransform  (Read 1285 times)
qbproger
developers
Becoming dependent
***
Offline Offline

Posts: 217


View Profile
« on: 22. May 2008, 11:13:40 pm »

The static transform is slower than it needs to be.  I was running the profiler and noticed a ton of objects being created.

I changed translate already to this:
Code:
public static void translate( GeomContainer src, float offsetX, float offsetY, float offsetZ )
    {
        //final Point3f[] vertices = GeometryUtils.getVertexCoords( src );
   
    Point3f pt = new Point3f();
    for(int i=0; i<src.getVertexCount(); i++)
    {
    src.getCoordinate(i, pt);
    pt.addX( offsetX );
    pt.addY( offsetY );
    pt.addZ( offsetZ );
    src.setCoordinate(i, pt);
    }
       
        //translate( vertices, offsetX, offsetY, offsetZ );
       
        //src.setCoordinates( 0, vertices );
    }

It took it from something like 900ms to < 50ms (for however many times I'm calling it).

final Point3f[] vertices = GeometryUtils.getVertexCoords( src );

creates an array and allocates a Point3f for each point in the GeomContainer.
Logged

Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 22. May 2008, 11:26:05 pm »

Good point. Thanks a lot. Will be committed soon.

Marvin
Logged
qbproger
developers
Becoming dependent
***
Offline Offline

Posts: 217


View Profile
« Reply #2 on: 22. May 2008, 11:32:12 pm »

It just occurred to me that using point pooling is probably better than creating a new point each time.
Logged

Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 23. May 2008, 12:00:08 am »

It just occurred to me that using point pooling is probably better than creating a new point each time.

Yeah, I have anyway used the pools in my local fix Wink.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #4 on: 23. May 2008, 12:11:34 am »

Committed.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic