void cPhysicsMaterialNewton::UpdateMaterials()
	{
		cPhysicsMaterialIterator MatIt = mpWorld->GetMaterialIterator();

		while(MatIt.HasNext())
		{
			cPhysicsMaterialNewton* pMat = static_cast<cPhysicsMaterialNewton*>(MatIt.Next());

			ePhysicsMaterialCombMode frictionMode =   (ePhysicsMaterialCombMode) std::max(mFrictionMode,
				pMat->mFrictionMode);
			ePhysicsMaterialCombMode elasticityMode = (ePhysicsMaterialCombMode) std::max(mElasticityMode,
				pMat->mElasticityMode);

			//If the material is the same do not blend.
			if(pMat == this){
				frictionMode = 	ePhysicsMaterialCombMode_Average;
				elasticityMode = ePhysicsMaterialCombMode_Average;
			}


			NewtonMaterialSetDefaultElasticity(mpNewtonWorld,mlMaterialId,pMat->mlMaterialId,
				Combine(elasticityMode,mfElasticity, pMat->mfElasticity));

			NewtonMaterialSetDefaultFriction(mpNewtonWorld,mlMaterialId,pMat->mlMaterialId,
				Combine(frictionMode,mfStaticFriction, pMat->mfStaticFriction),
				Combine(frictionMode,mfKineticFriction, pMat->mfKineticFriction));

			NewtonMaterialSetContinuousCollisionMode(mpNewtonWorld,mlMaterialId,pMat->mlMaterialId,
													1);

			NewtonMaterialSetCollisionCallback(mpNewtonWorld,mlMaterialId,pMat->mlMaterialId,
				(void*)NULL,BeginContactCallback,ProcessContactCallback);
		}
	}
Exemple #2
0
        world::world():
            _world(NULL),
            _accum(0),
            _freq(1.0 / 60.0)
        {
            // default to global gravity
            gravity.enabled = true;

            _world = NewtonCreate();
            const float WORLD_SIZE = 1000;
            const vec3 A(-WORLD_SIZE, -WORLD_SIZE, -WORLD_SIZE), B(-A);
            NewtonSetWorldSize(_world, &A.x, &B.x);

            platform(PLAT_OPTMIZED);
            solver(3);
            friction(FRIC_ADAPTIVE);
            threads(2);
            clearCache();

            int mid = NewtonMaterialGetDefaultGroupID(_world);
            // allow bodies to be swept-tested
            NewtonMaterialSetContinuousCollisionMode(_world, mid, mid, 1);
            NewtonMaterialSetCollisionCallback(_world, mid, mid, NULL,
                &beginContactCB, &processContactCB);
        }
Exemple #3
0
		void tContact::SetContinuousCollisionMode(int state)
		{
			NewtonMaterialSetContinuousCollisionMode(tWorld::Instance()->_getNewtonWorld(), mId0->GetId(), mId1->GetId(), state);
		}