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, 03:42:26 am
Xith3D CommunityXith3D InternalsDeveloper discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)sharedCopy with LODSwitch
Pages: [1]
Print
Author Topic: sharedCopy with LODSwitch  (Read 933 times)
qbproger
developers
Becoming dependent
***
Offline Offline

Posts: 217


View Profile
« on: 29. April 2008, 08:53:44 pm »

I ran into a problem with sharedCopy when using it with LODSwitch's

I did this to fix it, but I'm not sure this is the 100% solution.

Code:
public LODSwitch newInstance()
    {
    boolean gib = Node.globalIgnoreBounds;
        Node.globalIgnoreBounds = this.isIgnoreBounds();
        LODSwitch s = new LODSwitch( );
        Node.globalIgnoreBounds = gib;
       
        return( s );
    }
   
    public GroupNode sharedCopy()
    {
    GroupNode node = super.sharedCopy();
    if(node instanceof LODSwitch)
    {
    LODSwitch lod = (LODSwitch)node;
    lod.maxDistances = this.maxDistances;
    lod.minDistances = this.minDistances;
    }
   
    return node;
    }

newInstance was taken from Switch.
Logged

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

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 29. April 2008, 09:09:20 pm »

Looks almost perfect. Thanks for the fix. Though the min/max distance arrays need to be copied, since they would potentially run out of sync at some later time anyway.

I have applied this patch to the InputSystem branch. I will merger it into the trunk together with the rest of the InputSystem stuff.

Marvin
Logged
qbproger
developers
Becoming dependent
***
Offline Offline

Posts: 217


View Profile
« Reply #2 on: 29. April 2008, 09:21:12 pm »

How could they run out of sync at some later time?  I thought they just hold the values for switching in and out.  Shouldn't they be the same for all copies since the nodes beneath the LODSwitch are the same for all copies?
Logged

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

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 29. April 2008, 09:45:21 pm »

How could they run out of sync at some later time?  I thought they just hold the values for switching in and out.  Shouldn't they be the same for all copies since the nodes beneath the LODSwitch are the same for all copies?

The list of children in the GroupNodes/LODSwitches is not the same. They contain shared copies of the same children, but not the same instances and the lists are not the same.

So, when you add a new child to one of the shared copies, the other switch will not contain it. And if you add more children to one of the switches, than these arrays can hold, the arrays are expanded, which is the point in time, where they get out of sync.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic