OpenSim/Region/Physics/OdePlugin/OdeScene.cs
/// <summary>
/// Called when a static prim moves.  Allocates a space for the prim based on its position
/// </summary>
/// <param name="geom">the pointer to the geom that moved</param>
/// <param name="pos">the position that the geom moved to</param>
/// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
/// <returns>a pointer to the new space it's in</returns>
Called when a static prim moves.  Allocates a space for the prim based on its position
Called when a static prim moves . Allocates a space for the prim based on its position
internal IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace)
        {
            if (currentspace != space)
            {
                if (d.SpaceQuery(currentspace, geom) && currentspace != IntPtr.Zero)
                {
                    if (d.GeomIsSpace(currentspace))
                    {
                        d.SpaceRemove(currentspace, geom);
                    }
                    else
                    {
                        m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace +
                                   " Geom:" + geom);
                    }
                }
                else
                {
                    IntPtr sGeomIsIn = d.GeomGetSpace(geom);
                    if (sGeomIsIn != IntPtr.Zero)
                    {
                        if (d.GeomIsSpace(currentspace))
                        {
                            d.SpaceRemove(sGeomIsIn, geom);
                        }
                        else
                        {
                            m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                       sGeomIsIn + " Geom:" + geom);
                        }
                    }
                }
                if (d.SpaceGetNumGeoms(currentspace) == 0)
                {
                    if (currentspace != IntPtr.Zero)
                    {
                        if (d.GeomIsSpace(currentspace))
                        {
                            d.SpaceRemove(space, currentspace);
                            resetSpaceArrayItemToZero(currentspace);
                        }
                        else
                        {
                            m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                       currentspace + " Geom:" + geom);
                        }
                    }
                }
            }
            else
            {
                if (currentspace != IntPtr.Zero && geom != IntPtr.Zero)
                {
                    if (d.SpaceQuery(currentspace, geom))
                    {
                        if (d.GeomIsSpace(currentspace))
                        {
                            d.SpaceRemove(currentspace, geom);
                        }
                        else
                        {
                            m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                       currentspace + " Geom:" + geom);
                        }
                    }
                    else
                    {
                        IntPtr sGeomIsIn = d.GeomGetSpace(geom);
                        if (sGeomIsIn != IntPtr.Zero)
                        {
                            if (d.GeomIsSpace(sGeomIsIn))
                            {
                                d.SpaceRemove(sGeomIsIn, geom);
                            }
                            else
                            {
                                m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
                                           sGeomIsIn + " Geom:" + geom);
                            }
                        }
                    }
                }
            }
            int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos);
            IntPtr newspace = calculateSpaceForGeom(pos);
            if (newspace == IntPtr.Zero)
            {
                newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]);
                d.HashSpaceSetLevels(newspace, smallHashspaceLow, smallHashspaceHigh);
            }
            return newspace;
        }
internal IntPtr recalculateSpaceForGeom ( IntPtr geom , Vector3 pos , IntPtr currentspace ) { if ( currentspace != space ) { if ( d . SpaceQuery ( currentspace , geom ) && currentspace != IntPtr . Zero ) { if ( d . GeomIsSpace ( currentspace ) ) { d . SpaceRemove ( currentspace , geom ) ; } else { m_log . Info ( " " + currentspace + " " + geom ) ; } } else { IntPtr sGeomIsIn = d . GeomGetSpace ( geom ) ; if ( sGeomIsIn != IntPtr . Zero ) { if ( d . GeomIsSpace ( currentspace ) ) { d . SpaceRemove ( sGeomIsIn , geom ) ; } else { m_log . Info ( " " + sGeomIsIn + " " + geom ) ; } } } if ( d . SpaceGetNumGeoms ( currentspace ) == 0 ) { if ( currentspace != IntPtr . Zero ) { if ( d . GeomIsSpace ( currentspace ) ) { d . SpaceRemove ( space , currentspace ) ; resetSpaceArrayItemToZero ( currentspace ) ; } else { m_log . Info ( " " + currentspace + " " + geom ) ; } } } } else { if ( currentspace != IntPtr . Zero && geom != IntPtr . Zero ) { if ( d . SpaceQuery ( currentspace , geom ) ) { if ( d . GeomIsSpace ( currentspace ) ) { d . SpaceRemove ( currentspace , geom ) ; } else { m_log . Info ( " " + currentspace + " " + geom ) ; } } else { IntPtr sGeomIsIn = d . GeomGetSpace ( geom ) ; if ( sGeomIsIn != IntPtr . Zero ) { if ( d . GeomIsSpace ( sGeomIsIn ) ) { d . SpaceRemove ( sGeomIsIn , geom ) ; } else { m_log . Info ( " " + sGeomIsIn + " " + geom ) ; } } } } } int [ ] iprimspaceArrItem = calculateSpaceArrayItemFromPos ( pos ) ; IntPtr newspace = calculateSpaceForGeom ( pos ) ; if ( newspace == IntPtr . Zero ) { newspace = createprimspace ( iprimspaceArrItem [ 0 ] , iprimspaceArrItem [ 1 ] ) ; d . HashSpaceSetLevels ( newspace , smallHashspaceLow , smallHashspaceHigh ) ; } return newspace ; }
Called when a static prim moves.
Called when a static prim moves .
// Called from setting the Position and Size of an ODEPrim so // it's already in locked space. // we don't want to remove the main space // we don't need to test physical here because this function should // never be called if the prim is physical(active) // All physical prim end up in the root space //Thread.Sleep(20); //m_log.Info("[SPACE]: C:" + currentspace.ToString() + " g:" + geom.ToString()); //if (currentspace == IntPtr.Zero) //{ //int adfadf = 0; //} //                        waitForSpaceUnlock(currentspace); //                            waitForSpaceUnlock(sGeomIsIn); //If there are no more geometries in the sub-space, we don't need it in the main space anymore //                            waitForSpaceUnlock(currentspace); //                            waitForSpaceUnlock(space); // free up memory used by the space. //d.SpaceDestroy(currentspace); // this is a physical object that got disabled. ;.; //                            waitForSpaceUnlock(currentspace); //                                waitForSpaceUnlock(sGeomIsIn); // The routines in the Position and Size sections do the 'inserting' into the space, // so all we have to do is make sure that the space that we're putting the prim into // is in the 'main' space.
a pointer to the new space it's in
a pointer to the new space it ' s in
geom
IntPtr
the pointer to the geom that moved
the pointer to the geom that moved
pos
Vector3
the position that the geom moved to
the position that the geom moved to
currentspace
IntPtr
a pointer to the space it was in before it was moved.
a pointer to the space it was in before it was moved .