Add PhysicsEffects to Extras. The build is only tested on Windows and Android.
The Android/NEON optimized version of Physics Effects is thanks to Graham Rhodes and Anthony Hamilton, See Issue 587
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_BROADPHASE_H_
|
||||
#define _SCE_PFX_BROADPHASE_H_
|
||||
|
||||
#include "../../base_level/broadphase/pfx_broadphase_pair.h"
|
||||
#include "../../base_level/broadphase/pfx_broadphase_proxy.h"
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/collision/pfx_collidable.h"
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Update Broadphase Proxies
|
||||
|
||||
#define SCE_PFX_OUT_OF_WORLD_BEHAVIOR_FIX_MOTION 0x01
|
||||
#define SCE_PFX_OUT_OF_WORLD_BEHAVIOR_REMOVE_PROXY 0x02
|
||||
|
||||
struct PfxUpdateBroadphaseProxiesParam {
|
||||
void *workBuff;
|
||||
PfxUInt32 workBytes;
|
||||
PfxBroadphaseProxy *proxiesX;
|
||||
PfxBroadphaseProxy *proxiesY;
|
||||
PfxBroadphaseProxy *proxiesZ;
|
||||
PfxBroadphaseProxy *proxiesXb;
|
||||
PfxBroadphaseProxy *proxiesYb;
|
||||
PfxBroadphaseProxy *proxiesZb;
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxCollidable *offsetCollidables;
|
||||
PfxUInt32 numRigidBodies;
|
||||
PfxUInt32 outOfWorldBehavior;
|
||||
PfxVector3 worldCenter;
|
||||
PfxVector3 worldExtent;
|
||||
|
||||
PfxUpdateBroadphaseProxiesParam() : outOfWorldBehavior(0) {}
|
||||
};
|
||||
|
||||
struct PfxUpdateBroadphaseProxiesResult {
|
||||
PfxInt32 numOutOfWorldProxies;
|
||||
};
|
||||
|
||||
PfxUInt32 pfxGetWorkBytesOfUpdateBroadphaseProxies(PfxUInt32 numRigidBodies);
|
||||
|
||||
PfxUInt32 pfxGetWorkBytesOfUpdateBroadphaseProxies(PfxUInt32 numRigidBodies,PfxUInt32 maxTasks);
|
||||
|
||||
PfxInt32 pfxUpdateBroadphaseProxies(PfxUpdateBroadphaseProxiesParam ¶m,PfxUpdateBroadphaseProxiesResult &result);
|
||||
|
||||
PfxInt32 pfxUpdateBroadphaseProxies(PfxUpdateBroadphaseProxiesParam ¶m,PfxUpdateBroadphaseProxiesResult &result,PfxTaskManager *taskManager);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Find Pairs
|
||||
|
||||
struct PfxFindPairsParam {
|
||||
void *workBuff;
|
||||
PfxUInt32 workBytes;
|
||||
void *pairBuff;
|
||||
PfxUInt32 pairBytes;
|
||||
PfxBroadphaseProxy *proxies;
|
||||
PfxUInt32 numProxies;
|
||||
PfxUInt32 maxPairs;
|
||||
int axis;
|
||||
};
|
||||
|
||||
struct PfxFindPairsResult {
|
||||
PfxBroadphasePair *pairs;
|
||||
PfxUInt32 numPairs;
|
||||
};
|
||||
|
||||
PfxUInt32 pfxGetWorkBytesOfFindPairs(PfxUInt32 maxPairs,PfxUInt32 maxTasks=1);
|
||||
PfxUInt32 pfxGetPairBytesOfFindPairs(PfxUInt32 maxPairs);
|
||||
|
||||
PfxInt32 pfxFindPairs(PfxFindPairsParam ¶m,PfxFindPairsResult &result);
|
||||
|
||||
PfxInt32 pfxFindPairs(PfxFindPairsParam ¶m,PfxFindPairsResult &result,PfxTaskManager *taskManager);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Decompose Pairs
|
||||
|
||||
struct PfxDecomposePairsParam {
|
||||
void *workBuff;
|
||||
PfxUInt32 workBytes;
|
||||
void *pairBuff;
|
||||
PfxUInt32 pairBytes;
|
||||
PfxBroadphasePair *previousPairs;
|
||||
PfxUInt32 numPreviousPairs;
|
||||
PfxBroadphasePair *currentPairs;
|
||||
PfxUInt32 numCurrentPairs;
|
||||
};
|
||||
|
||||
struct PfxDecomposePairsResult {
|
||||
PfxBroadphasePair *outNewPairs;
|
||||
PfxUInt32 numOutNewPairs;
|
||||
PfxBroadphasePair *outKeepPairs;
|
||||
PfxUInt32 numOutKeepPairs;
|
||||
PfxBroadphasePair *outRemovePairs;
|
||||
PfxUInt32 numOutRemovePairs;
|
||||
};
|
||||
|
||||
PfxUInt32 pfxGetWorkBytesOfDecomposePairs(PfxUInt32 numPreviousPairs,PfxUInt32 numCurrentPairs,int maxTasks=1);
|
||||
PfxUInt32 pfxGetPairBytesOfDecomposePairs(PfxUInt32 numPreviousPairs,PfxUInt32 numCurrentPairs);
|
||||
|
||||
PfxInt32 pfxDecomposePairs(PfxDecomposePairsParam ¶m,PfxDecomposePairsResult &result);
|
||||
|
||||
PfxInt32 pfxDecomposePairs(PfxDecomposePairsParam ¶m,PfxDecomposePairsResult &result,PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
#endif /* _SCE_PFX_BROADPHASE_H_ */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_BATCHED_RAY_CAST_H
|
||||
#define _SCE_PFX_BATCHED_RAY_CAST_H
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/collision/pfx_collidable.h"
|
||||
#include "../../base_level/broadphase/pfx_broadphase_proxy.h"
|
||||
#include "../task/pfx_task_manager.h"
|
||||
#include "pfx_ray_cast.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Batched RayCast
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
void pfxCastRays(PfxRayInput *rayInputs,PfxRayOutput *rayOutputs,int numRays,PfxRayCastParam ¶m);
|
||||
|
||||
void pfxCastRays(PfxRayInput *rayInputs,PfxRayOutput *rayOutputs,int numRays,PfxRayCastParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif // _SCE_PFX_BATCHED_RAY_CAST_H
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_COLLISION_DETECTION_H_
|
||||
#define _SCE_PFX_COLLISION_DETECTION_H_
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/collision/pfx_collidable.h"
|
||||
#include "../../base_level/collision/pfx_contact_manifold.h"
|
||||
#include "../../base_level/solver/pfx_constraint_pair.h"
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Detect Collision
|
||||
|
||||
struct PfxDetectCollisionParam {
|
||||
PfxConstraintPair *contactPairs;
|
||||
PfxUInt32 numContactPairs;
|
||||
PfxContactManifold *offsetContactManifolds;
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxCollidable *offsetCollidables;
|
||||
PfxUInt32 numRigidBodies;
|
||||
};
|
||||
|
||||
PfxInt32 pfxDetectCollision(PfxDetectCollisionParam ¶m);
|
||||
|
||||
PfxInt32 pfxDetectCollision(PfxDetectCollisionParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif /* _SCE_PFX_COLLISION_DETECTION_H_ */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_ISLAND_GENERATION_H_
|
||||
#define _SCE_PFX_ISLAND_GENERATION_H_
|
||||
|
||||
#include "../../base_level/solver/pfx_constraint_pair.h"
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Island Generation
|
||||
|
||||
struct PfxIsland;
|
||||
struct PfxIslandUnit;
|
||||
|
||||
struct PfxGenerateIslandParam {
|
||||
void *islandBuff;
|
||||
PfxUInt32 islandBytes;
|
||||
PfxConstraintPair *pairs;
|
||||
PfxUInt32 numPairs;
|
||||
PfxUInt32 numObjects;
|
||||
};
|
||||
|
||||
struct PfxGenerateIslandResult {
|
||||
PfxIsland *island;
|
||||
};
|
||||
|
||||
//J アイランド情報を使い終わるまでislandBuffを破棄しないでください
|
||||
//E Keep islandBuff while the island is used
|
||||
PfxUInt32 pfxGetIslandBytesOfGenerateIsland(PfxUInt32 numObjects);
|
||||
|
||||
PfxInt32 pfxGenerateIsland(PfxGenerateIslandParam ¶m,PfxGenerateIslandResult &result);
|
||||
|
||||
//E Access to island information
|
||||
//J アイランド情報へのアクセス
|
||||
|
||||
//E Get the number of islands
|
||||
//J アイランド数を取得する
|
||||
PfxUInt32 pfxGetNumIslands(const PfxIsland *islands);
|
||||
|
||||
//E Get a island unit in a island
|
||||
//J 指定したアイランドに含まれるユニット(剛体)にアクセス
|
||||
PfxIslandUnit *pfxGetFirstUnitInIsland(const PfxIsland *islands,PfxUInt32 islandId);
|
||||
PfxIslandUnit *pfxGetNextUnitInIsland(const PfxIslandUnit *islandUnit);
|
||||
PfxUInt32 pfxGetUnitId(const PfxIslandUnit *islandUnit);
|
||||
|
||||
//E Get an index of an island which includes a specific unit
|
||||
//J 指定したユニット(剛体)のアイランドインデックスを取得する
|
||||
PfxUInt32 pfxGetIslandId(const PfxIsland *islands,PfxUInt32 unitId);
|
||||
|
||||
//E Add pairs and construct islands
|
||||
//J アイランドにペアを追加する
|
||||
PfxInt32 pfxAppendPairs(PfxIsland *island,PfxConstraintPair *pairs,PfxUInt32 numPairs);
|
||||
|
||||
//E Reset islands
|
||||
//J アイランドリセット
|
||||
void pfxResetIsland(PfxIsland *island);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif /* _SCE_PFX_ISLAND_GENERATION_H_ */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_RAY_CAST_H
|
||||
#define _SCE_PFX_RAY_CAST_H
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/collision/pfx_collidable.h"
|
||||
#include "../../base_level/collision/pfx_ray.h"
|
||||
#include "../../base_level/broadphase/pfx_broadphase_proxy.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// RayCast
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
struct PfxRayCastParam {
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxCollidable *offsetCollidables;
|
||||
PfxBroadphaseProxy *proxiesX;
|
||||
PfxBroadphaseProxy *proxiesY;
|
||||
PfxBroadphaseProxy *proxiesZ;
|
||||
PfxBroadphaseProxy *proxiesXb;
|
||||
PfxBroadphaseProxy *proxiesYb;
|
||||
PfxBroadphaseProxy *proxiesZb;
|
||||
PfxUInt32 numProxies;
|
||||
SCE_PFX_PADDING(1,12)
|
||||
PfxVector3 rangeCenter;
|
||||
PfxVector3 rangeExtent;
|
||||
};
|
||||
|
||||
void pfxCastSingleRay(const PfxRayInput &rayInput,PfxRayOutput &rayOutput,const PfxRayCastParam ¶m);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
#endif // _SCE_PFX_RAY_CAST_H
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_REFRESH_CONTACTS_H
|
||||
#define _SCE_PFX_REFRESH_CONTACTS_H
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/solver/pfx_constraint_pair.h"
|
||||
#include "../../base_level/collision/pfx_contact_manifold.h"
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Refresh Contacts
|
||||
|
||||
struct PfxRefreshContactsParam {
|
||||
PfxConstraintPair *contactPairs;
|
||||
PfxUInt32 numContactPairs;
|
||||
PfxContactManifold *offsetContactManifolds;
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxUInt32 numRigidBodies;
|
||||
};
|
||||
|
||||
PfxInt32 pfxRefreshContacts(PfxRefreshContactsParam ¶m);
|
||||
|
||||
PfxInt32 pfxRefreshContacts(PfxRefreshContactsParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif // _SCE_PFX_REFRESH_CONTACTS_H
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_LOW_LEVEL_INCLUDE_H
|
||||
#define _SCE_PFX_LOW_LEVEL_INCLUDE_H
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Physics Effects Low Level Headers
|
||||
|
||||
// Include base level headers
|
||||
#include "../base_level/pfx_base_level_include.h"
|
||||
|
||||
// Include low level headers
|
||||
#include "broadphase/pfx_broadphase.h"
|
||||
|
||||
#include "collision/pfx_collision_detection.h"
|
||||
#include "collision/pfx_refresh_contacts.h"
|
||||
#include "collision/pfx_batched_ray_cast.h"
|
||||
#include "collision/pfx_ray_cast.h"
|
||||
#include "collision/pfx_island_generation.h"
|
||||
|
||||
#include "solver/pfx_constraint_solver.h"
|
||||
#include "solver/pfx_update_rigid_states.h"
|
||||
|
||||
#include "sort/pfx_parallel_sort.h"
|
||||
|
||||
// ARA begin insert new code
|
||||
#ifdef USE_PTHREADS
|
||||
#include "task/pfx_pthreads.h"
|
||||
#endif
|
||||
// ARA end
|
||||
|
||||
#endif // _SCE_PFX_LOW_LEVEL_INCLUDE_H
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_CONSTRAINT_SOLVER_H
|
||||
#define _SCE_PFX_CONSTRAINT_SOLVER_H
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_body.h"
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/solver/pfx_solver_body.h"
|
||||
#include "../../base_level/solver/pfx_constraint_pair.h"
|
||||
#include "../../base_level/solver/pfx_joint.h"
|
||||
#include "../../base_level/collision/pfx_contact_manifold.h"
|
||||
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Setup Solver Bodies
|
||||
|
||||
struct PfxSetupSolverBodiesParam {
|
||||
PfxRigidState *states;
|
||||
PfxRigidBody *bodies;
|
||||
PfxSolverBody *solverBodies;
|
||||
PfxUInt32 numRigidBodies;
|
||||
};
|
||||
|
||||
PfxInt32 pfxSetupSolverBodies(PfxSetupSolverBodiesParam ¶m);
|
||||
|
||||
PfxInt32 pfxSetupSolverBodies(PfxSetupSolverBodiesParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Setup Constraints
|
||||
|
||||
struct PfxSetupContactConstraintsParam {
|
||||
PfxConstraintPair *contactPairs;
|
||||
PfxUInt32 numContactPairs;
|
||||
PfxContactManifold *offsetContactManifolds;
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxRigidBody *offsetRigidBodies;
|
||||
PfxSolverBody *offsetSolverBodies;
|
||||
PfxUInt32 numRigidBodies;
|
||||
PfxFloat timeStep;
|
||||
PfxFloat separateBias;
|
||||
|
||||
PfxSetupContactConstraintsParam()
|
||||
{
|
||||
timeStep = 0.016f;
|
||||
separateBias = 0.2f;
|
||||
}
|
||||
};
|
||||
|
||||
PfxInt32 pfxSetupContactConstraints(PfxSetupContactConstraintsParam ¶m);
|
||||
|
||||
PfxInt32 pfxSetupContactConstraints(PfxSetupContactConstraintsParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
struct PfxSetupJointConstraintsParam {
|
||||
PfxConstraintPair *jointPairs;
|
||||
PfxUInt32 numJointPairs;
|
||||
PfxJoint *offsetJoints;
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxRigidBody *offsetRigidBodies;
|
||||
PfxSolverBody *offsetSolverBodies;
|
||||
PfxUInt32 numRigidBodies;
|
||||
PfxFloat timeStep;
|
||||
|
||||
PfxSetupJointConstraintsParam()
|
||||
{
|
||||
timeStep = 0.016f;
|
||||
}
|
||||
};
|
||||
|
||||
PfxInt32 pfxSetupJointConstraints(PfxSetupJointConstraintsParam ¶m);
|
||||
|
||||
PfxInt32 pfxSetupJointConstraints(PfxSetupJointConstraintsParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Solve Constraints
|
||||
|
||||
struct PfxSolveConstraintsParam {
|
||||
void *workBuff;
|
||||
PfxUInt32 workBytes;
|
||||
PfxConstraintPair *contactPairs;
|
||||
PfxUInt32 numContactPairs;
|
||||
PfxContactManifold *offsetContactManifolds;
|
||||
PfxConstraintPair *jointPairs;
|
||||
PfxUInt32 numJointPairs;
|
||||
PfxJoint *offsetJoints;
|
||||
PfxRigidState *offsetRigidStates;
|
||||
PfxSolverBody *offsetSolverBodies;
|
||||
PfxUInt32 numRigidBodies;
|
||||
PfxUInt32 iteration;
|
||||
|
||||
PfxSolveConstraintsParam()
|
||||
{
|
||||
iteration = 5;
|
||||
}
|
||||
};
|
||||
|
||||
PfxUInt32 pfxGetWorkBytesOfSolveConstraints(PfxUInt32 numRigidBodies,PfxUInt32 numContactPairs,PfxUInt32 numJointPairs,PfxUInt32 maxTasks=1);
|
||||
|
||||
PfxInt32 pfxSolveConstraints(PfxSolveConstraintsParam ¶m);
|
||||
|
||||
PfxInt32 pfxSolveConstraints(PfxSolveConstraintsParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
#endif // _SCE_PFX_CONSTRAINT_SOLVER_H
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_JOINT_CONSTRAINT_FUNC_H_
|
||||
#define _SCE_PFX_JOINT_CONSTRAINT_FUNC_H_
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
#include "../../base_level/solver/pfx_solver_body.h"
|
||||
#include "../../base_level/solver/pfx_joint.h"
|
||||
#include "../../base_level/solver/pfx_joint_constraint.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Setup Joint Constraint Func
|
||||
|
||||
typedef void (*PfxSetupJointConstraintFunc)(
|
||||
PfxJoint &joint,
|
||||
const PfxRigidState &stateA,
|
||||
const PfxRigidState &stateB,
|
||||
PfxSolverBody &solverBodyA,
|
||||
PfxSolverBody &solverBodyB,
|
||||
PfxFloat timeStep);
|
||||
|
||||
PfxSetupJointConstraintFunc pfxGetSetupJointConstraintFunc(PfxUInt8 jointType);
|
||||
|
||||
int pfxSetSetupJointConstraintFunc(PfxUInt8 jointType,PfxSetupJointConstraintFunc func);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Warm Start Joint Constraint Func
|
||||
|
||||
typedef void (*PfxWarmStartJointConstraintFunc)(
|
||||
PfxJoint &joint,
|
||||
PfxSolverBody &solverBodyA,
|
||||
PfxSolverBody &solverBodyB);
|
||||
|
||||
PfxWarmStartJointConstraintFunc pfxGetWarmStartJointConstraintFunc(PfxUInt8 jointType);
|
||||
|
||||
int pfxSetWarmStartJointConstraintFunc(PfxUInt8 jointType,PfxWarmStartJointConstraintFunc func);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Solve Joint Constraint Func
|
||||
|
||||
typedef void (*PfxSolveJointConstraintFunc)(
|
||||
PfxJoint &joint,
|
||||
PfxSolverBody &solverBodyA,
|
||||
PfxSolverBody &solverBodyB);
|
||||
|
||||
PfxSolveJointConstraintFunc pfxGetSolveJointConstraintFunc(PfxUInt8 jointType);
|
||||
|
||||
int pfxSetSolveJointConstraintFunc(PfxUInt8 jointType,PfxSolveJointConstraintFunc func);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif /* _PFX_JOINT_CONSTRAINT_FUNC_H_ */
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_UPDATE_RIGID_STATES_H_
|
||||
#define _SCE_PFX_UPDATE_RIGID_STATES_H_
|
||||
|
||||
#include "../../base_level/rigidbody/pfx_rigid_body.h"
|
||||
#include "../../base_level/rigidbody/pfx_rigid_state.h"
|
||||
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Update Rigid Body States
|
||||
|
||||
struct PfxUpdateRigidStatesParam {
|
||||
PfxRigidState *states;
|
||||
PfxRigidBody *bodies;
|
||||
PfxUInt32 numRigidBodies;
|
||||
PfxFloat timeStep;
|
||||
};
|
||||
|
||||
PfxInt32 pfxUpdateRigidStates(PfxUpdateRigidStatesParam ¶m);
|
||||
|
||||
PfxInt32 pfxUpdateRigidStates(PfxUpdateRigidStatesParam ¶m,PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif /* _SCE_PFX_UPDATE_RIGID_STATES_H_ */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_PARALLEL_SORT_H
|
||||
#define _SCE_PFX_PARALLEL_SORT_H
|
||||
|
||||
#include "../../base_level/sort/pfx_sort_data.h"
|
||||
#include "../task/pfx_task_manager.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Parallel Sort
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
PfxInt32 pfxParallelSort(PfxSortData16 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes);
|
||||
|
||||
PfxInt32 pfxParallelSort(PfxSortData32 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes);
|
||||
|
||||
PfxInt32 pfxParallelSort(PfxSortData16 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes,
|
||||
PfxTaskManager *taskManager);
|
||||
|
||||
PfxInt32 pfxParallelSort(PfxSortData32 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes,
|
||||
PfxTaskManager *taskManager);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
#endif // _SCE_PFX_PARALLEL_SORT_H
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Applied Research Associates Inc. (c)2011
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Applied Research Associates Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_PTHREADS_H
|
||||
#define _SCE_PFX_PTHREADS_H
|
||||
|
||||
#include "../../base_level/base/pfx_common.h"
|
||||
#include <errno.h>
|
||||
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
class PfxBarrier;
|
||||
class PfxCriticalSection;
|
||||
class PfxTaskManager;
|
||||
|
||||
#define SCE_PFX_CHECK_PTHREADS_OUTCOME(result) \
|
||||
if(0 != result) \
|
||||
{ \
|
||||
SCE_PFX_PRINTF("pthreads problem at line %i in file %s: %i %d\n", __LINE__, __FILE__, result, errno); \
|
||||
}
|
||||
|
||||
PfxBarrier *PfxCreateBarrierPthreads(int n);
|
||||
PfxCriticalSection *PfxCreateCriticalSectionPthreads();
|
||||
PfxTaskManager *PfxCreateTaskManagerPthreads(PfxUInt32 numTasks,PfxUInt32 maxTasks,void *workBuff,PfxUInt32 workBytes);
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
|
||||
#endif // _SCE_PFX_PTHREADS_H
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_SYNC_COMPONENTS_H
|
||||
#define _SCE_PFX_SYNC_COMPONENTS_H
|
||||
|
||||
#include "../../base_level/base/pfx_common.h"
|
||||
|
||||
//J スレッド間の同期をとるための同期コンポネント
|
||||
//E Components for threads sychronization
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
class PfxBarrier {
|
||||
public:
|
||||
PfxBarrier() {}
|
||||
virtual ~PfxBarrier() {}
|
||||
|
||||
virtual void sync() = 0;
|
||||
virtual void setMaxCount(int n) = 0;
|
||||
virtual int getMaxCount() = 0;
|
||||
};
|
||||
|
||||
class PfxCriticalSection {
|
||||
public:
|
||||
PfxCriticalSection() {}
|
||||
virtual ~PfxCriticalSection() {}
|
||||
|
||||
PfxUInt32 m_commonBuff[32];
|
||||
|
||||
virtual PfxUInt32 getSharedParam(int i) = 0;
|
||||
virtual void setSharedParam(int i,PfxUInt32 p) = 0;
|
||||
|
||||
virtual void lock() = 0;
|
||||
virtual void unlock() = 0;
|
||||
};
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
#endif // _SCE_PFX_SYNC_COMPONENTS_H
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef _SCE_PFX_TASK_MANAGER_H
|
||||
#define _SCE_PFX_TASK_MANAGER_H
|
||||
|
||||
#include "../../base_level/base/pfx_common.h"
|
||||
#include "../../base_level/base/pfx_heap_manager.h"
|
||||
#include "pfx_sync_components.h"
|
||||
|
||||
#define SCE_PFX_IO_BUFF_BYTES 1048576
|
||||
namespace sce {
|
||||
namespace PhysicsEffects {
|
||||
|
||||
//J 並列処理するためのタスクマネージャクラス
|
||||
//E Task manager class for parallel computation
|
||||
|
||||
struct PfxTaskArg
|
||||
{
|
||||
int taskId;
|
||||
int maxTasks;
|
||||
PfxBarrier *barrier;
|
||||
PfxCriticalSection *criticalSection;
|
||||
void *io;
|
||||
PfxUInt32 data[4];
|
||||
};
|
||||
|
||||
typedef void (*PfxTaskEntry)(PfxTaskArg *arg);
|
||||
|
||||
class PfxTaskManager
|
||||
{
|
||||
protected:
|
||||
PfxUInt32 m_numTasks;
|
||||
PfxUInt32 m_maxTasks;
|
||||
SCE_PFX_PADDING(1,4)
|
||||
PfxUInt8 SCE_PFX_ALIGNED(16) m_ioBuff[SCE_PFX_IO_BUFF_BYTES];
|
||||
PfxHeapManager m_pool;
|
||||
PfxHeapManager m_ioPool;
|
||||
PfxTaskEntry m_taskEntry;
|
||||
PfxTaskArg *m_taskArg;
|
||||
SCE_PFX_PADDING(2,8)
|
||||
|
||||
PfxTaskManager() : m_pool(NULL,0),m_ioPool(NULL,0) {}
|
||||
|
||||
public:
|
||||
void *allocate(size_t bytes) {return m_ioPool.allocate(bytes);}
|
||||
void deallocate(void *p) {m_ioPool.deallocate(p);}
|
||||
void clearPool() {m_ioPool.clear();}
|
||||
|
||||
virtual PfxUInt32 getSharedParam(int i) = 0;
|
||||
virtual void setSharedParam(int i,PfxUInt32 p) = 0;
|
||||
|
||||
virtual void startTask(int taskId,void *io,PfxUInt32 data1,PfxUInt32 data2,PfxUInt32 data3,PfxUInt32 data4) = 0;
|
||||
virtual void waitTask(int &taskId,PfxUInt32 &data1,PfxUInt32 &data2,PfxUInt32 &data3,PfxUInt32 &data4) = 0;
|
||||
|
||||
virtual void setTaskEntry(void *entry) {m_taskEntry = (PfxTaskEntry)entry;}
|
||||
|
||||
public:
|
||||
PfxTaskManager(PfxUInt32 numTasks,PfxUInt32 maxTasks,void *workBuff,PfxUInt32 workBytes)
|
||||
: m_pool((unsigned char*)workBuff,workBytes),m_ioPool(m_ioBuff,SCE_PFX_IO_BUFF_BYTES)
|
||||
{
|
||||
SCE_PFX_ASSERT(numTasks>0);
|
||||
SCE_PFX_ASSERT(numTasks<=maxTasks);
|
||||
m_numTasks = numTasks;
|
||||
m_maxTasks = maxTasks;
|
||||
m_taskArg = (PfxTaskArg*)m_pool.allocate(sizeof(PfxTaskArg)*m_maxTasks);
|
||||
}
|
||||
|
||||
virtual ~PfxTaskManager()
|
||||
{
|
||||
m_pool.clear();
|
||||
}
|
||||
|
||||
virtual PfxUInt32 getNumTasks() const {return m_numTasks;}
|
||||
virtual void setNumTasks(PfxUInt32 tasks) {m_numTasks = SCE_PFX_MIN(tasks,m_maxTasks);}
|
||||
|
||||
virtual void initialize() = 0;
|
||||
virtual void finalize() = 0;
|
||||
};
|
||||
|
||||
} //namespace PhysicsEffects
|
||||
} //namespace sce
|
||||
#endif // _SCE_PFX_TASK_MANAGER_H
|
||||
Reference in New Issue
Block a user