예제 #1
0
	ODESpace::ODESpace()
	{
		// Create the Space without adding it to another Space.
        if (false)
            mSpaceID = dSimpleSpaceCreate(0);
        else
        {
            mSpaceID = dHashSpaceCreate(0);
            dHashSpaceSetLevels(mSpaceID, 3, 9);
        }
		mParentSpaceID = NULL;
	}
void PhysicsHashSpace::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    //Do not respond to changes that have a Sync origin
    if(origin & ChangedOrigin::Sync)
    {
        return;
    }

    if(whichField & LevelsFieldMask)
    {
	    dHashSpaceSetLevels(_SpaceID, (Int32)getLevels().x(), (Int32)getLevels().y());
    }
}
예제 #3
0
	void ODESimulator::initData(SimulatorData data)
	{
		Simulator::initData(data);

		// We can only init ODE once.
		if (0 == mInitCounter)
		{
			dInitODE();
		}
		++mInitCounter;

		// Create ODE world.
		mWorldID = dWorldCreate();

		// Set default gravity.
		setGravity(defaults::gravity);

		// Create the root ODE space.
		//mRootSpaceID = dSimpleSpaceCreate(0);
		//dVector3 center = {0, 0, 0};
		//dVector3 extents = {200, 100, 200};
		//mRootSpaceID = dQuadTreeSpaceCreate(0, center, extents, 5);

		if (data.useOctreeInsteadHash)
		{
			dVector3 center = { data.worldCenter[0],
			                    data.worldCenter[1],
			                    data.worldCenter[2] };
			dVector3 extents = { data.worldSize[0],
			                     data.worldSize[1],
			                     data.worldSize[2] };
			mRootSpaceID = dQuadTreeSpaceCreate(0, center, extents, data.octreeDepth);
		}
		else
		{
			mRootSpaceID = dHashSpaceCreate(0);
			dHashSpaceSetLevels(mRootSpaceID, data.hashMinLevel, data.hashMaxLevel);
		}

		mRootSpace = new ODESpace(mRootSpaceID);

		// Create the ODE contact joint group.
		mContactJointGroupID = dJointGroupCreate(0);

		// Set the ODE global CFM value that will be used by all Joints
		// (including contacts).  This affects normal Joint constraint
		// operation and Joint limits.  The user cannot adjust CFM, but
		// they can adjust ERP (a.k.a. bounciness/restitution) for materials
		// (i.e. contact settings) and Joint limits.
		dWorldSetCFM(mWorldID, defaults::ode::globalCFM);

		// Set the ODE global ERP value.  This will only be used for Joints
		// under normal conditions, not at their limits.  Also, it will not
		// affect contacts at all since they use material properties to
		// calculate ERP.
		dWorldSetERP(mWorldID, (real) 0.5 * (defaults::ode::maxERP +
		              defaults::ode::minERP));

		dWorldSetContactSurfaceLayer(mWorldID, defaults::ode::surfaceLayer);

		setSolverAccuracy(defaults::solverAccuracy);
		mCollisionCount = 0;
		// "mRaycastResult" is initialized in its own constructor.
		mSensorSolid = NULL;
		mRayContactGroup = defaults::shape::contactGroup;
	}