#include "StdAfx.h" #include "vtPhysXAll.h" #include "IParameter.h" #include "vtStructHelper.h" static IParameter* gIPar = NULL; #include "pMisc.h" #include "pVehicleAll.h" using namespace vtTools::ParameterTools; int IParameter::copyTo(pLinearInterpolation& dst,CKParameter*src) { if (!src) return false; int gear = 0; float ratio = 0.0f; CKStructHelper sHelper(src); if (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects. return -1; for (int i = 0 ; i < sHelper.GetMemberCount() ; i++) { CK_ID* paramids = static_cast(src->GetReadDataPtr()); CKParameter * sub = static_cast(GetPMan()->m_Context->GetObject(paramids[i])); if (sub) { dst.insert(GetValueFromParameterStruct(sub,0,false), GetValueFromParameterStruct(sub,1,false) ); } } return true; } int IParameter::copyTo(pGearBox *dst,CKParameter*src) { if (!src || !dst) return false; int gear = 0; float ratio = 0.0f; for (int i = 0 ; i < 7 ; i++) { CK_ID* paramids = static_cast(src->GetReadDataPtr()); CKParameter * sub = static_cast(GetPMan()->m_Context->GetObject(paramids[i])); if (sub) { dst->gearRatio[i] = GetValueFromParameterStruct(sub,0,false); dst->gearInertia[i] = GetValueFromParameterStruct(sub,1,false); dst->getGearRatios().insert((float)i,dst->gearRatio[i]); dst->getGearTensors().insert((float)i,dst->gearInertia[i]); } } return true; } int IParameter::copyTo(pVehicleBrakeTable& dst,CKParameter*src) { int result = 0; for (int i = 0 ; i < BREAK_TABLE_ENTRIES ; i ++) dst.brakeEntries[i] = GetValueFromParameterStruct(src,i); return true; } int IParameter::copyTo(CKParameter*dst,pWheelDescr src) { if (!dst)return false; using namespace vtTools::ParameterTools; int result = 0; SetParameterStructureValue(dst,E_WD_SPRING_BIAS,src.springBias,false); SetParameterStructureValue(dst,E_WD_SPRING_RES,src.springRestitution,false); SetParameterStructureValue(dst,E_WD_DAMP,src.springDamping,false); SetParameterStructureValue(dst,E_WD_MAX_BFORCE,src.maxBrakeForce,false); SetParameterStructureValue(dst,E_WD_FFRONT,src.frictionToFront,false); SetParameterStructureValue(dst,E_WD_FSIDE,src.frictionToSide,false); SetParameterStructureValue(dst,E_WD_FLAGS,src.wheelFlags,false); SetParameterStructureValue(dst,E_WD_INVERSE_WHEEL_MASS,src.inverseWheelMass,false); SetParameterStructureValue(dst,E_WD_SFLAGS,src.wheelShapeFlags,false); SetParameterStructureValue(dst,E_WD_SUSPENSION,src.wheelSuspension,false); } int IParameter::copyTo(pWheelDescr& dst,CKParameter*src) { int result = 1; if (!src) { return NULL; } using namespace vtTools::ParameterTools; dst.wheelSuspension = GetValueFromParameterStruct(src,E_WD_SUSPENSION); dst.springRestitution= GetValueFromParameterStruct(src,E_WD_SPRING_RES); dst.springBias = GetValueFromParameterStruct(src,E_WD_SPRING_BIAS); dst.springDamping= GetValueFromParameterStruct(src,E_WD_DAMP); dst.maxBrakeForce= GetValueFromParameterStruct(src,E_WD_MAX_BFORCE); dst.frictionToSide= GetValueFromParameterStruct(src,E_WD_FSIDE); dst.frictionToFront= GetValueFromParameterStruct(src,E_WD_FFRONT); CKParameterOut *pOld = GetParameterFromStruct(src,E_WD_INVERSE_WHEEL_MASS); if (pOld) { if (pOld->GetGUID() == CKPGUID_FLOAT) { dst.inverseWheelMass= GetValueFromParameterStruct(src,E_WD_INVERSE_WHEEL_MASS); } if (pOld->GetGUID() == CKPGUID_INT) { dst.wheelApproximation= GetValueFromParameterStruct(src,E_WD_INVERSE_WHEEL_MASS); } } dst.wheelFlags= (WheelFlags)GetValueFromParameterStruct(src,E_WD_FLAGS); dst.wheelShapeFlags=(WheelShapeFlags) GetValueFromParameterStruct(src,E_WD_SFLAGS); CKParameterOut *parLatFunc = GetParameterFromStruct(src,E_WD_LAT_FUNC); CKParameterOut *parLongFunc = GetParameterFromStruct(src,E_WD_LONG_FUNC); /************************************************************************/ /* XML Setup ? */ /************************************************************************/ int xmlLinkId= GetValueFromParameterStruct(src,E_WD_XML); bool wIsXML=false; bool latIsXML= false; bool longIsXML=false; XString nodeName; if ( xmlLinkId !=0 ) { nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_WHEEL_SETTINGS,xmlLinkId); pFactory::Instance()->loadWheelDescrFromXML(dst,nodeName.CStr(),pFactory::Instance()->getDefaultDocument()); wIsXML =true; if (!dst.isValid()) { xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,"Wheel Description was invalid"); } if (dst.latFunc.xmlLink!=0) { latIsXML=true; } if (dst.longFunc.xmlLink!=0) { longIsXML=true; } } if (!latIsXML) { dst.latFunc = pFactory::Instance()->createTireFuncFromParameter(parLatFunc); } if (!longIsXML) { dst.longFunc= pFactory::Instance()->createTireFuncFromParameter(parLongFunc); } if (wIsXML) { IParameter::Instance()->copyTo((CKParameterOut*)src,dst); } if (longIsXML) { pFactory::Instance()->copyTo(GetParameterFromStruct(src,E_WD_LONG_FUNC),dst.longFunc); } if (latIsXML) { pFactory::Instance()->copyTo(GetParameterFromStruct(src,E_WD_LAT_FUNC),dst.latFunc); } return result; } int IParameter::copyTo(pConvexCylinderSettings& dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; copyTo(dst.radius, GetParameterFromStruct(src,PS_CC_RADIUS_REFERENCED_VALUE),true); copyTo(dst.height, GetParameterFromStruct(src,PS_CC_HEIGHT_REFERENCED_VALUE),true); dst.approximation = GetValueFromParameterStruct(src,PS_CC_APPROXIMATION); dst.buildLowerHalfOnly = GetValueFromParameterStruct(src,PS_CC_BUILD_LOWER_HALF_ONLY); dst.convexFlags = (pConvexFlags)GetValueFromParameterStruct(src,PS_CC_EXTRA_SHAPE_FLAGS); //---------------------------------------------------------------- // // Calculate Forward Axis, optionally referenced by an entity // dst.forwardAxis = GetValueFromParameterStruct(src,PS_CC_FORWARD_AXIS); dst.forwardAxisRef = GetValueFromParameterStruct(src,PS_CC_FORWARD_AXIS_REF); CK3dEntity *f = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.forwardAxisRef); if (f) { VxVector dir,up,right; f->GetOrientation(&dir,&up,&right); f->TransformVector(&dst.forwardAxis,&dir); dst.forwardAxis.Normalize(); } //---------------------------------------------------------------- // // Calculate Down Axis, optionally referenced by an entity // dst.downAxis = GetValueFromParameterStruct(src,PS_CC_DOWN_AXIS); dst.downAxisRef = GetValueFromParameterStruct(src,PS_CC_DOWN_AXIS_REF); CK3dEntity *d = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.downAxisRef); if (d) { VxVector dir,up,right; d->GetOrientation(&dir,&up,&right); d->TransformVector(&dst.downAxis,&up); dst.downAxis.Normalize(); } //---------------------------------------------------------------- // // Calculate Right Axis, optionally referenced by an entity // dst.rightAxis = GetValueFromParameterStruct(src,PS_CC_RIGHT_AXIS); dst.rightAxisRef = GetValueFromParameterStruct(src,PS_CC_RIGHT_AXIS_REF); CK3dEntity *r = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.rightAxisRef); if (r) { VxVector dir,up,right; r->GetOrientation(&dir,&up,&right); r->TransformVector(&dst.rightAxis,&right); dst.rightAxis.Normalize(); } return 1; } int IParameter::copyTo(CKParameter*dst,pConvexCylinderSettings& src) { copyTo(src.radius, GetParameterFromStruct(dst,PS_CC_RADIUS_REFERENCED_VALUE),true); copyTo(src.height, GetParameterFromStruct(dst,PS_CC_HEIGHT_REFERENCED_VALUE),true); SetParameterStructureValue(dst,PS_CC_APPROXIMATION,src.approximation,false); SetParameterStructureValue(dst,PS_CC_BUILD_LOWER_HALF_ONLY,src.buildLowerHalfOnly,false); SetParameterStructureValue(dst,PS_CC_EXTRA_SHAPE_FLAGS,src.convexFlags,false); SetParameterStructureValue(dst,PS_CC_FORWARD_AXIS,src.forwardAxis,false); SetParameterStructureValue(dst,PS_CC_DOWN_AXIS,src.downAxis,false); SetParameterStructureValue(dst,PS_CC_RIGHT_AXIS,src.rightAxis,false); CK3dEntity *f = (CK3dEntity*)GetPMan()->m_Context->GetObject(src.forwardAxisRef); if (f) SetParameterStructureValue(dst,PS_CC_FORWARD_AXIS_REF,f->GetID(),false); CK3dEntity *d = (CK3dEntity*)GetPMan()->m_Context->GetObject(src.downAxisRef); if (d) SetParameterStructureValue(dst,PS_CC_DOWN_AXIS_REF,d->GetID(),false); CK3dEntity *r = (CK3dEntity*)GetPMan()->m_Context->GetObject(src.rightAxisRef); if (r) SetParameterStructureValue(dst,PS_CC_RIGHT_AXIS_REF,r->GetID(),false); return 1; } int IParameter::copyTo(pMassSettings& dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; dst.newDensity= GetValueFromParameterStruct(src,PS_BM_DENSITY,false); dst.totalMass= GetValueFromParameterStruct(src,PS_BM_TOTAL_MASS,false); dst.localPosition = GetValueFromParameterStruct(src,PS_BM_PIVOT_POS,false); dst.localOrientation = GetValueFromParameterStruct(src,PS_BM_PIVOT_ROTATION,false); dst.massReference= GetValueFromParameterStruct(src,PS_BM_PIVOT_REFERENCE,false); return 1; } int IParameter::copyTo(CKParameter*dst,pMassSettings src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(dst); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; SetParameterStructureValue(dst,PS_BM_DENSITY,src.newDensity,false); SetParameterStructureValue(dst,PS_BM_TOTAL_MASS,src.totalMass,false); SetParameterStructureValue(dst,PS_BM_PIVOT_POS,src.localPosition,false); SetParameterStructureValue(dst,PS_BM_PIVOT_ROTATION,src.localOrientation,false); SetParameterStructureValue(dst,PS_BM_PIVOT_REFERENCE,src.massReference,false); return 1; } int IParameter::copyTo(CKParameter*dst,pPivotSettings src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(dst); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; SetParameterStructureValue(dst,PS_BP_LINEAR,src.localPosition,false); SetParameterStructureValue(dst,PS_BP_ANGULAR,src.localOrientation,false); SetParameterStructureValue(dst,PS_BP_REFERENCE,src.pivotReference,false); /* dst.localPosition = GetValueFromParameterStruct(src,PS_BP_LINEAR,false); dst.localOrientation = GetValueFromParameterStruct(src,PS_BP_ANGULAR,false); dst.pivotReference = GetValueFromParameterStruct(src,PS_BP_REFERENCE,false); */ return 1; } int IParameter::copyTo(pPivotSettings& dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; dst.localPosition = GetValueFromParameterStruct(src,PS_BP_LINEAR,false); dst.localOrientation = GetValueFromParameterStruct(src,PS_BP_ANGULAR,false); dst.pivotReference = GetValueFromParameterStruct(src,PS_BP_REFERENCE,false); return 1; } int IParameter::copyTo(pObjectDescr&dst,CK3dEntity*src,int copyFlags) { pRigidBody *srcBody = GetPMan()->getBody(src); NxActor *actor = NULL; pObjectDescr*initDescr = NULL; NxShape *mainShape= NULL; //---------------------------------------------------------------- // // sanity checks // if (!src || !srcBody || !srcBody->getMainShape()) return 0; initDescr = srcBody->getInitialDescription(); actor = srcBody->getActor(); mainShape = srcBody->getMainShape(); if (!initDescr || !actor ) return 0; //---------------------------------------------------------------- // // general settings // dst.hullType = (HullType)vtAgeia::getHullTypeFromShape(srcBody->getMainShape()); srcBody->recalculateFlags(0); dst.flags = (BodyFlags)srcBody->getFlags(); dst.worlReference = srcBody->getWorld()->getReference()->GetID(); dst.density = initDescr->density; dst.mask = initDescr->mask; //---------------------------------------------------------------- // // specific override : optimization // if ( (copyFlags & PB_CF_OPTIMIZATION) ) { //---------------------------------------------------------------- // // damping + sleeping // dst.optimization.angDamping = actor->getAngularDamping(); dst.optimization.linDamping = actor->getLinearDamping(); dst.optimization.linSleepVelocity = actor->getSleepLinearVelocity(); dst.optimization.angSleepVelocity = actor->getSleepAngularVelocity(); dst.optimization.sleepEnergyThreshold = actor->getSleepEnergyThreshold(); //---------------------------------------------------------------- // // transformation flags // dst.optimization.transformationFlags = (BodyLockFlags)srcBody->getTransformationsLockFlags(); dst.optimization.solverIterations = actor->getSolverIterationCount(); dst.optimization.dominanceGroup = actor->getDominanceGroup(); dst.optimization.compartmentGroup = initDescr->optimization.compartmentGroup; } //---------------------------------------------------------------- // // specific override : collision // //if ( (dst.mask & OD_Optimization ) ) if ( (copyFlags & PB_CF_COLLISION ) ) { dst.collisionGroup = mainShape->getGroup(); NxGroupsMask nxMask = mainShape->getGroupsMask(); dst.groupsMask.bits0 = nxMask.bits0; dst.groupsMask.bits1 = nxMask.bits1; dst.groupsMask.bits2 = nxMask.bits2; dst.groupsMask.bits3 = nxMask.bits3; dst.skinWidth = mainShape->getSkinWidth(); } //---------------------------------------------------------------- // // specific override : ccd // //if ( (dst.mask & OD_CCD) ) if ( (copyFlags & OD_CCD ) && (dst.mask & OD_CCD) ) { dst.ccd.flags = initDescr->ccd.flags; dst.ccd.meshReference = initDescr->ccd.meshReference; dst.ccd.motionThresold = initDescr->ccd.motionThresold; dst.ccd.scale = initDescr->ccd.scale; } //---------------------------------------------------------------- // // specific override : capsule // if ( (copyFlags && OD_Capsule) && (dst.mask & OD_Capsule) ) dst.capsule = initDescr->capsule; //---------------------------------------------------------------- // // specific override : convex cylinder // if ( (copyFlags && OD_ConvexCylinder) && (dst.mask & OD_ConvexCylinder) ) dst.convexCylinder = initDescr->convexCylinder; //---------------------------------------------------------------- // // specific override : material // if ( (copyFlags && OD_Material) && (dst.mask & OD_Material) ) dst.material = initDescr->material; //---------------------------------------------------------------- // // specific override : pivot // if ( (copyFlags && OD_Pivot) ) { //dst.pivotOffsetAngular = getFrom(mainShape->getLocalOrientation() ); dst.pivotOffsetLinear = getFrom( mainShape->getLocalPosition() ); //dst.pivotOffsetReference= initDescr->pivotOffsetReference; } if ( (copyFlags && PB_CF_MASS_SETTINGS) ) { //dst.pivotOffsetAngular = getFrom(mainShape->getLocalOrientation() ); dst.massOffsetLinear = getFrom(actor->getCMassLocalPosition()); //dst.pivotOffsetReference= initDescr->pivotOffsetReference; } //---------------------------------------------------------------- // // correct data mask : // DWORD mask = (DWORD)(dst.mask); mask &=~((OD_Pivot)); if ( !(copyFlags & PB_CF_PIVOT_SETTINGS) ) mask &=~((OD_Pivot)); if ( !(copyFlags & PB_CF_MASS_SETTINGS) ) mask &=~(OD_Mass); if ( !(copyFlags & PB_CF_OPTIMIZATION) ) mask &=~(OD_Optimization); if ( !(copyFlags & PB_CF_COLLISION) ) mask &=~(OD_Collision); if ( !(copyFlags & PB_CF_CCD) ) mask &=~(OD_CCD); if ( !(copyFlags & PB_CF_CAPSULE) ) mask &=~(OD_Capsule); if ( !(copyFlags & PB_CF_CONVEX_CYLINDER) ) mask&=~(OD_ConvexCylinder); if ( !(copyFlags & PB_CF_MATERIAL) ) mask &=~(OD_Material); return 1; } int IParameter::copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate) { #ifdef _DEBUG assert(src); #endif using namespace vtTools::ParameterTools; //################################################################ // // Retrieve the value : // dst.value = GetValueFromParameterStruct(src,PS_ARL_VALUE); dst.referenceAxis = GetValueFromParameterStruct(src,PS_ARL_REF_OBJECT_AXIS); //################################################################ // // Calculate the value basing on the given objects local box and an axis. // CK_ID idRef= GetValueFromParameterStruct(src,PS_ARL_REF_OBJECT); CKBeObject *object = (CKBeObject*)GetPMan()->GetContext()->GetObject(idRef); if (!object) return -1; dst.reference = object; if (!evaluate)return -1; VxVector size(0.0f); if (object->GetClassID() == CKCID_3DOBJECT ) { CK3dEntity *ent3D = (CK3dEntity*)object; if (ent3D) { size = ent3D->GetBoundingBox(true).GetSize(); } }else if(object->GetClassID() == CKCID_MESH) { CKMesh *mesh = (CKMesh*)object; if (mesh) { size = mesh->GetLocalBox().GetSize(); } } dst.value = size[dst.referenceAxis]; return 1; } int IParameter::copyTo(CKParameter *dst, pAxisReferencedLength &src, bool evaluate) { SetParameterStructureValue(dst,PS_ARL_VALUE,src.value,false); SetParameterStructureValue(dst,PS_ARL_REF_OBJECT_AXIS,src.referenceAxis,false); if (src.reference) { SetParameterStructureValue(dst,PS_ARL_REF_OBJECT,src.reference->GetID(),false); } return 1; } int IParameter::copyTo(pCapsuleSettingsEx& dst,CKParameter*src) { //SetParameterStructureValue(dst,PS_BM_DENSITY,src.newDensity,false); //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; pFactory::Instance()->copyTo(dst.radius, GetParameterFromStruct(src,PS_BCAPSULE_RADIUS_REFERENCED_VALUE),false); pFactory::Instance()->copyTo(dst.height, GetParameterFromStruct(src,PS_PCAPSULE_HEIGHT_REFERENCED_VALUE),false); return 1; } int IParameter::copyTo(CKParameter*dst,pCapsuleSettingsEx src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(dst); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; copyTo(GetParameterFromStruct(dst,PS_BCAPSULE_RADIUS_REFERENCED_VALUE),src.radius,false); copyTo(GetParameterFromStruct(dst,PS_PCAPSULE_HEIGHT_REFERENCED_VALUE),src.height,false); return 1; } int IParameter::copyTo(pCCDSettings& dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; //---------------------------------------------------------------- // // general // dst.flags = GetValueFromParameterStruct(src,PS_B_CCD_FLAGS,false); dst.motionThresold = GetValueFromParameterStruct(src,PS_B_CCD_MOTION_THRESHOLD,false); dst.scale= GetValueFromParameterStruct(src,PS_B_CCD_SCALE,false); dst.meshReference= GetValueFromParameterStruct(src,PS_B_CCD_MESH_REFERENCE,false); return 1; } int IParameter::copyTo(pOptimization& dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; //---------------------------------------------------------------- // // Retrieve all sub parameters : // CKParameterOut *parSleeping = GetParameterFromStruct(src,PS_BO_SLEEPING); CKParameterOut *parDamping = GetParameterFromStruct(src,PS_BO_DAMPING); //---------------------------------------------------------------- // // general // dst.transformationFlags = (BodyLockFlags) GetValueFromParameterStruct(src,PS_BO_LOCKS,false); dst.solverIterations = GetValueFromParameterStruct(src,PS_BO_SOLVER_ITERATIONS,false); dst.compartmentGroup = GetValueFromParameterStruct(src,PS_BO_COMPARTMENT_ID,false); dst.dominanceGroup = GetValueFromParameterStruct(src,PS_BO_DOMINANCE_GROUP,false); //---------------------------------------------------------------- // // Sleeping // dst.angSleepVelocity = GetValueFromParameterStruct(parSleeping,PS_BS_ANGULAR_SLEEP,false); dst.linSleepVelocity = GetValueFromParameterStruct(parSleeping,PS_BS_LINEAR_SLEEP,false); dst.sleepEnergyThreshold = GetValueFromParameterStruct(parSleeping,PS_BS_THRESHOLD,false); //---------------------------------------------------------------- // // Damping // dst.angDamping = GetValueFromParameterStruct(parDamping,PS_BD_ANGULAR,false); dst.linDamping= GetValueFromParameterStruct(parDamping,PS_BD_LINEAR,false); return 1; } int IParameter::copyTo(CKParameter*dst,pObjectDescr*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(dst); assert(src); #endif using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; //---------------------------------------------------------------- // // Retrieve all sub parameters : // CKParameterOut *parBCommon = GetParameterFromStruct(dst,PS_COMMON_SETTINGS); CKParameterOut *parBCollision = GetParameterFromStruct(dst,PS_COLLISION_SETTINGS); //CKParameterOut *parBCCD = GetParameterFromStruct(parBCollision,PS_BC_CCD_SETUP); CKParameterOut *parGroupsMask = GetParameterFromStruct(parBCollision,PS_BC_GROUPSMASK); #ifdef _DEBUG assert(parBCommon); //assert(parBPivot); //assert(parBCCD); assert(parBCollision); #endif ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // // transfer // //---------------------------------------------------------------- // // common // SetParameterStructureValue(parBCommon,PS_BC_HULL_TYPE,src->hullType); SetParameterStructureValue(parBCommon,PS_BC_DENSITY,src->density); SetParameterStructureValue(parBCommon,PS_BC_FLAGS,src->flags); SetParameterStructureValue(parBCommon,PS_BC_WORLD,src->worlReference); //---------------------------------------------------------------- // // XML // //---------------------------------------------------------------- // // Collision // SetParameterStructureValue(parBCollision,PS_BC_GROUP,src->collisionGroup); SetParameterStructureValue(parBCollision,PS_BC_SKINWITDH,src->skinWidth); SetParameterStructureValue(parGroupsMask,0,src->groupsMask.bits0); SetParameterStructureValue(parGroupsMask,1,src->groupsMask.bits1); SetParameterStructureValue(parGroupsMask,2,src->groupsMask.bits2); SetParameterStructureValue(parGroupsMask,3,src->groupsMask.bits3); //---------------------------------------------------------------- // // CCD // /* SetParameterStructureValue(parBCCD,PS_B_CCD_MOTION_THRESHOLD,src->ccdMotionThresold); SetParameterStructureValue(parBCCD,PS_B_CCD_FLAGS,src->ccdFlags); SetParameterStructureValue(parBCCD,PS_B_CCD_MESH_REFERENCE,src->ccdMeshReference); SetParameterStructureValue(parBCCD,PS_B_CCD_SCALE,src->ccdScale); */ return 1; } int IParameter::copyTo(pCollisionSettings &dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(src); #endif using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; CKParameterOut *parGroupsMask = GetParameterFromStruct(src,PS_BC_GROUPSMASK); // Sanity checks #ifdef _DEBUG assert(parGroupsMask); #endif //---------------------------------------------------------------- // // Collision Setup // dst.collisionGroup = GetValueFromParameterStruct(src,PS_BC_GROUP,false); // dst.groupsMask.bits0 = GetValueFromParameterStruct(parGroupsMask,0); dst.groupsMask.bits1 = GetValueFromParameterStruct(parGroupsMask,1); dst.groupsMask.bits2 = GetValueFromParameterStruct(parGroupsMask,2); dst.groupsMask.bits3 = GetValueFromParameterStruct(parGroupsMask,3); dst.skinWidth = GetValueFromParameterStruct(src,PS_BC_SKINWITDH,false); return 1; } int IParameter::copyTo(pObjectDescr*dst,CKParameter*src) { //---------------------------------------------------------------- // // Sanity checks // #ifdef _DEBUG assert(dst); assert(src); #endif //---------------------------------------------------------------- // // Possible this function is invoked due the loading of a cmo file whilst core is not started yet : // CKStructHelper sHelper(src); if(sHelper.GetMemberCount() == 0) return 0; using namespace vtTools::AttributeTools; using namespace vtTools::ParameterTools; //---------------------------------------------------------------- // // Retrieve all sub parameters : // CKParameterOut *parBCommon = GetParameterFromStruct(src,PS_COMMON_SETTINGS); //CKParameterOut *parBPivot = GetParameterFromStruct(src,PS_PIVOT); //CKParameterOut *parBMass = GetParameterFromStruct(src,PS_MASS); CKParameterOut *parBCollision = GetParameterFromStruct(src,PS_COLLISION_SETTINGS); //CKParameterOut *parBCCD = GetParameterFromStruct(parBCollision,PS_BC_CCD_SETUP); CKParameterOut *parGroupsMask = GetParameterFromStruct(parBCollision,PS_BC_GROUPSMASK); #ifdef _DEBUG assert(parBCommon); //assert(parBPivot); //assert(parBMass); assert(parBCollision); #endif //---------------------------------------------------------------- // // Common settings as hull type, body flags, ... // dst->hullType =(HullType)GetValueFromParameterStruct(parBCommon,PS_BC_HULL_TYPE,false); dst->flags = (BodyFlags)GetValueFromParameterStruct(parBCommon,PS_BC_FLAGS,false); /*dst->transformationFlags = GetValueFromParameterStruct(parBCommon,PS_BC_TFLAGS,false);*/ dst->worlReference = GetValueFromParameterStruct(parBCommon,PS_BC_WORLD,false); dst->density = GetValueFromParameterStruct(parBCommon,PS_BC_DENSITY,false); //---------------------------------------------------------------- // // Pivot Offset // /* dst->pivotOffsetLinear = GetValueFromParameterStruct(parBPivot,PS_BP_LINEAR,false); dst->pivotOffsetAngular = GetValueFromParameterStruct(parBPivot,PS_BP_ANGULAR,false); //---------------------------------------------------------------- // // Mass Offset // dst->density = GetValueFromParameterStruct(parBMass,PS_BM_DENSITY,false); dst->totalMass = GetValueFromParameterStruct(parBMass,PS_BM_TOTAL_MASS,false); dst->massOffsetLinear = GetValueFromParameterStruct(parBMass,PS_BM_PIVOT_POS,false); */ //dst->massOffsetAngular = GetValueFromParameterStruct(parBMass,PS_BM_PIVOT_ROTATION,false); //---------------------------------------------------------------- // // Collision Setup // dst->collisionGroup = GetValueFromParameterStruct(parBCollision,PS_BC_GROUP,false); // dst->groupsMask.bits0 = GetValueFromParameterStruct(parGroupsMask,0); dst->groupsMask.bits1 = GetValueFromParameterStruct(parGroupsMask,1); dst->groupsMask.bits2 = GetValueFromParameterStruct(parGroupsMask,2); dst->groupsMask.bits3 = GetValueFromParameterStruct(parGroupsMask,3); dst->skinWidth = GetValueFromParameterStruct(parBCollision,PS_BC_SKINWITDH,false); dst->collision.groupsMask.bits0 = GetValueFromParameterStruct(parGroupsMask,0); dst->collision.groupsMask.bits1 = GetValueFromParameterStruct(parGroupsMask,1); dst->collision.groupsMask.bits2 = GetValueFromParameterStruct(parGroupsMask,2); dst->collision.groupsMask.bits3 = GetValueFromParameterStruct(parGroupsMask,3); dst->collision.skinWidth = GetValueFromParameterStruct(parBCollision,PS_BC_SKINWITDH,false); dst->collision.collisionGroup = GetValueFromParameterStruct(parBCollision,PS_BC_GROUP,false); //---------------------------------------------------------------- // // CCD Settings // /*dst->ccdFlags = GetValueFromParameterStruct(parBCCD,PS_B_CCD_FLAGS,false); dst->ccdMotionThresold= GetValueFromParameterStruct(parBCCD,PS_B_CCD_MOTION_THRESHOLD,false); dst->ccdScale = GetValueFromParameterStruct(parBCCD,PS_B_CCD_SCALE,false); dst->ccdMeshReference = GetValueFromParameterStruct(parBCCD,PS_B_CCD_MESH_REFERENCE,false); */ dst->mask << OD_Collision; //---------------------------------------------------------------- // // Misc // dst->version = pObjectDescr::E_OD_VERSION::OD_DECR_V1; return 1; } IParameter* IParameter::Instance() { if (!gIPar) { gIPar = new IParameter(GetPMan()); } return gIPar; } IParameter::IParameter(PhysicManager*_pManager) : mManager(_pManager) { gIPar = this; }