First of all, I’m new here (I’m just looking for some help)
I have this code (this worked in 3.2 version)
void CamouflageDataManager::UpdateCamouflageData(const GameObject &o)
{
const r3dVector &pos = o.GetPosition();
PxVec3 orig(pos.x, pos.y + 0.5f, pos.z);
static const PxVec3 dirs[5] =
{
PxVec3( 0, -1, 0),
PxVec3( 1, 0, 0),
PxVec3(-1, 0, 0),
PxVec3( 0, 0, -1),
PxVec3( 0, 0, 1)
};
PxRaycastHit hit;
float closest = std::numeric_limits<float>::max();
PhysicsCallbackObject* target = 0;
uint32_t faceId = 0;
r3dVector impactPos(0, 0, 0);
for (int i = 0; i < _countof(dirs); ++i)
{
PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK,0,0,0), PxSceneQueryFilterFlags(PxSceneQueryFilterFlag::eDYNAMIC | PxSceneQueryFilterFlag::eSTATIC));
if(g_pPhysicsWorld->raycastSingle(orig, dirs[i], 5.0f, PxHitFlags(PxHitFlag::ePOSITION), hit, filter))
{
r3dVector hitPos(hit.position.x, hit.position.y, hit.position.z);
float dist = (hitPos - pos).LengthSq();
if (dist < closest)
{
r3d_assert(hit.shape);
target = static_cast<PhysicsCallbackObject*>(hit.shape->getActor().userData);
faceId = hit.faceIndex;
closest = dist;
impactPos = hitPos;
}
}
/*
PxHitFlag::ePOSITION changed to PxHitFlag::ePOSITION
PxRaycastHit.impact renamed to PxRaycastHit.position (same for PxSweepHit.impact)
PxQueryFlag::eNO_BLOCK and PxQueryFlag::eANY_HIT flags were added
/*/
}
r3dTexture * newCamoTex = 0;
if (target)
{
r3dMaterial *material = 0;
GameObject *gameObj = target->isGameObject();
if (gameObj)
{
if (gameObj->isObjType(OBJTYPE_Mesh))
{
material = static_cast<MeshGameObject*>(target)->MeshLOD[0]->GetFaceMaterial(faceId);
}
if (gameObj->isObjType(OBJTYPE_Terrain))
{
newCamoTex = Terrain->GetDominantTexture( impactPos ) ;
}
}
else if (target->GetMaterial(faceId))
{
material = target->GetMaterial(faceId);
}
else if (target->hasMesh())
{
material = target->hasMesh()->GetFaceMaterial(faceId);
}
if (material)
{
newCamoTex = material->Texture;
}
r3dMaterial::CamoData cd = GetCamouflageData(o);
float currT = r3dGetTime();
// This is for abrupt texture changes
float camoPhase = currT - cd.transitionStartTime;
if (camoPhase > CAMOUFLAGE_LERP_DURATION)
{
cd.prevTex = cd.curTex;
cd.curTex = newCamoTex;
cd.transitionStartTime = currT;
dataStorage.AddAndReplace(o.GetHashID(), cd);
}
}
}
but after of updating to 3.3 I’m getting this error left of ‘.userData’ must have class/struct/union
Second :
How can fix this error in physx 3.3
: ‘physx::PxScene::overlapAny’ : cannot convert parameter 3 from ‘physx::PxShape *’ to ‘physx::PxOverlapHit &’
bool force_prone = false;
if(pl->bProne)
{
PxBoxGeometry bbox(0.2f, 0.9f, 0.2f);
PxTransform pose(PxVec3(pl->GetPosition().x, pl->GetPosition().y+1.1f, pl->GetPosition().z), PxQuat(0,0,0,1));
PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC);
PxShape* shape;
force_prone = g_pPhysicsWorld->PhysXScene->overlapAny(bbox, pose, shape, filter);
}
And the last :
PxCookingParams cookingParams;
Cooking = PxCreateCooking(PX_PHYSICS_VERSION, PhysXSDK->getFoundation(), cookingParams);
if(!Cooking)
{
r3dError("Failed to init PhysX Cooking");
}
CookingParms don’t work anymore ? Error ‘physx::PxCookingParams’ : no appropriate default constructor available