feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -249,9 +249,14 @@ void ContactConstraintManager::CachedBodyPair::RestoreState(StateRecorder &inStr
|
|||
|
||||
void ContactConstraintManager::ManifoldCache::Init(uint inMaxBodyPairs, uint inMaxContactConstraints, uint inCachedManifoldsSize)
|
||||
{
|
||||
mAllocator.Init(inMaxBodyPairs * sizeof(BodyPairMap::KeyValue) + inCachedManifoldsSize);
|
||||
uint max_body_pairs = min(inMaxBodyPairs, cMaxBodyPairsLimit);
|
||||
JPH_ASSERT(max_body_pairs == inMaxBodyPairs, "Cannot support this many body pairs!");
|
||||
JPH_ASSERT(inMaxContactConstraints <= cMaxContactConstraintsLimit); // Should have been enforced by caller
|
||||
|
||||
mAllocator.Init(uint(min(uint64(max_body_pairs) * sizeof(BodyPairMap::KeyValue) + inCachedManifoldsSize, uint64(~uint(0)))));
|
||||
|
||||
mCachedManifolds.Init(GetNextPowerOf2(inMaxContactConstraints));
|
||||
mCachedBodyPairs.Init(GetNextPowerOf2(inMaxBodyPairs));
|
||||
mCachedBodyPairs.Init(GetNextPowerOf2(max_body_pairs));
|
||||
}
|
||||
|
||||
void ContactConstraintManager::ManifoldCache::Clear()
|
||||
|
|
@ -676,14 +681,18 @@ ContactConstraintManager::~ContactConstraintManager()
|
|||
|
||||
void ContactConstraintManager::Init(uint inMaxBodyPairs, uint inMaxContactConstraints)
|
||||
{
|
||||
mMaxConstraints = inMaxContactConstraints;
|
||||
// Limit the number of constraints so that the allocation size fits in an unsigned integer
|
||||
mMaxConstraints = min(inMaxContactConstraints, cMaxContactConstraintsLimit);
|
||||
JPH_ASSERT(mMaxConstraints == inMaxContactConstraints, "Cannot support this many contact constraints!");
|
||||
|
||||
// Calculate worst case cache usage
|
||||
uint cached_manifolds_size = inMaxContactConstraints * (sizeof(CachedManifold) + (MaxContactPoints - 1) * sizeof(CachedContactPoint));
|
||||
constexpr uint cMaxManifoldSizePerConstraint = sizeof(CachedManifold) + (MaxContactPoints - 1) * sizeof(CachedContactPoint);
|
||||
static_assert(cMaxManifoldSizePerConstraint < sizeof(ContactConstraint)); // If not true, then the next line can overflow
|
||||
uint cached_manifolds_size = mMaxConstraints * cMaxManifoldSizePerConstraint;
|
||||
|
||||
// Init the caches
|
||||
mCache[0].Init(inMaxBodyPairs, inMaxContactConstraints, cached_manifolds_size);
|
||||
mCache[1].Init(inMaxBodyPairs, inMaxContactConstraints, cached_manifolds_size);
|
||||
mCache[0].Init(inMaxBodyPairs, mMaxConstraints, cached_manifolds_size);
|
||||
mCache[1].Init(inMaxBodyPairs, mMaxConstraints, cached_manifolds_size);
|
||||
}
|
||||
|
||||
void ContactConstraintManager::PrepareConstraintBuffer(PhysicsUpdateContext *inContext)
|
||||
|
|
|
|||
|
|
@ -472,6 +472,14 @@ private:
|
|||
WorldContactPoints mContactPoints;
|
||||
};
|
||||
|
||||
public:
|
||||
/// The maximum value that can be passed to Init for inMaxContactConstraints. Note you should really use a lower value, using this value will cost a lot of memory!
|
||||
static constexpr uint cMaxContactConstraintsLimit = ~uint(0) / sizeof(ContactConstraint);
|
||||
|
||||
/// The maximum value that can be passed to Init for inMaxBodyPairs. Note you should really use a lower value, using this value will cost a lot of memory!
|
||||
static constexpr uint cMaxBodyPairsLimit = ~uint(0) / sizeof(BodyPairMap::KeyValue);
|
||||
|
||||
private:
|
||||
/// Internal helper function to calculate the friction and non-penetration constraint properties. Templated to the motion type to reduce the amount of branches and calculations.
|
||||
template <EMotionType Type1, EMotionType Type2>
|
||||
JPH_INLINE void TemplatedCalculateFrictionAndNonPenetrationConstraintProperties(ContactConstraint &ioConstraint, const ContactSettings &inSettings, float inDeltaTime, Vec3Arg inGravityDeltaTime, RMat44Arg inTransformBody1, RMat44Arg inTransformBody2, const Body &inBody1, const Body &inBody2);
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ void HingeConstraint::SetLimits(float inLimitsMin, float inLimitsMax)
|
|||
JPH_ASSERT(inLimitsMax >= 0.0f && inLimitsMax <= JPH_PI);
|
||||
mLimitsMin = inLimitsMin;
|
||||
mLimitsMax = inLimitsMax;
|
||||
mHasLimits = mLimitsMin > -JPH_PI && mLimitsMax < JPH_PI;
|
||||
mHasLimits = mLimitsMin > -JPH_PI || mLimitsMax < JPH_PI;
|
||||
}
|
||||
|
||||
void HingeConstraint::CalculateA1AndTheta()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue