mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 00:46:41 +02:00
use DynamicsWorld::numCollisionObjects instead of our own count
This commit is contained in:
parent
abf4a926d8
commit
10d0833c19
7 changed files with 13 additions and 18 deletions
|
@ -61,7 +61,7 @@ Item {
|
|||
text: "Game Rate: " + root.gameLoopRate
|
||||
}
|
||||
StatText {
|
||||
text: "Physics Body Count: " + root.physicsBodyCount
|
||||
text: "Physics Object Count: " + root.physicsObjectCount
|
||||
}
|
||||
StatText {
|
||||
visible: root.expanded
|
||||
|
|
|
@ -6184,8 +6184,8 @@ bool Application::isHMDMode() const {
|
|||
return getActiveDisplayPlugin()->isHmd();
|
||||
}
|
||||
|
||||
float Application::getNumRigidBodies() const {
|
||||
return _physicsEngine ? _physicsEngine->getNumRigidBodies() : 0;
|
||||
float Application::getNumCollisionObjects() const {
|
||||
return _physicsEngine ? _physicsEngine->getNumCollisionObjects() : 0;
|
||||
}
|
||||
|
||||
float Application::getTargetRenderFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); }
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
|
||||
size_t getRenderFrameCount() const { return _renderFrameCount; }
|
||||
float getRenderLoopRate() const { return _renderLoopCounter.rate(); }
|
||||
float getNumRigidBodies() const;
|
||||
float getNumCollisionObjects() const;
|
||||
float getTargetRenderFrameRate() const; // frames/second
|
||||
|
||||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
|
|
|
@ -121,7 +121,7 @@ void Stats::updateStats(bool force) {
|
|||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||
// we need to take one avatar out so we don't include ourselves
|
||||
STAT_UPDATE(avatarCount, avatarManager->size() - 1);
|
||||
STAT_UPDATE(physicsBodyCount, qApp->getNumRigidBodies());
|
||||
STAT_UPDATE(physicsObjectCount, qApp->getNumCollisionObjects());
|
||||
STAT_UPDATE(updatedAvatarCount, avatarManager->getNumAvatarsUpdated());
|
||||
STAT_UPDATE(notUpdatedAvatarCount, avatarManager->getNumAvatarsNotUpdated());
|
||||
STAT_UPDATE(serverCount, (int)nodeList->size());
|
||||
|
|
|
@ -49,7 +49,7 @@ private: \
|
|||
* @property {number} presentdroprate - <em>Read-only.</em>
|
||||
* @property {number} gameLoopRate - <em>Read-only.</em>
|
||||
* @property {number} avatarCount - <em>Read-only.</em>
|
||||
* @property {number} physicsBodyCount - <em>Read-only.</em>
|
||||
* @property {number} physicsObjectCount - <em>Read-only.</em>
|
||||
* @property {number} updatedAvatarCount - <em>Read-only.</em>
|
||||
* @property {number} notUpdatedAvatarCount - <em>Read-only.</em>
|
||||
* @property {number} packetInCount - <em>Read-only.</em>
|
||||
|
@ -196,7 +196,7 @@ class Stats : public QQuickItem {
|
|||
STATS_PROPERTY(float, presentdroprate, 0)
|
||||
STATS_PROPERTY(int, gameLoopRate, 0)
|
||||
STATS_PROPERTY(int, avatarCount, 0)
|
||||
STATS_PROPERTY(int, physicsBodyCount, 0)
|
||||
STATS_PROPERTY(int, physicsObjectCount, 0)
|
||||
STATS_PROPERTY(int, updatedAvatarCount, 0)
|
||||
STATS_PROPERTY(int, notUpdatedAvatarCount, 0)
|
||||
STATS_PROPERTY(int, packetInCount, 0)
|
||||
|
@ -413,7 +413,7 @@ signals:
|
|||
* @function Stats.numPhysicsBodiesChanged
|
||||
* @returns {Signal}
|
||||
*/
|
||||
void physicsBodyCountChanged();
|
||||
void physicsObjectCountChanged();
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when the value of the <code>avatarCount</code> property changes.
|
||||
|
|
|
@ -77,6 +77,10 @@ uint32_t PhysicsEngine::getNumSubsteps() const {
|
|||
return _dynamicsWorld->getNumSubsteps();
|
||||
}
|
||||
|
||||
int32_t PhysicsEngine::getNumCollisionObjects() const {
|
||||
return _dynamicsWorld ? _dynamicsWorld->getNumCollisionObjects() : 0;
|
||||
}
|
||||
|
||||
// private
|
||||
void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) {
|
||||
assert(motionState);
|
||||
|
@ -93,7 +97,6 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) {
|
|||
btCollisionShape* shape = const_cast<btCollisionShape*>(motionState->getShape());
|
||||
assert(shape);
|
||||
body = new btRigidBody(mass, motionState, shape, inertia);
|
||||
++_numRigidBodies;
|
||||
motionState->setRigidBody(body);
|
||||
} else {
|
||||
body->setMassProps(mass, inertia);
|
||||
|
@ -117,7 +120,6 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) {
|
|||
shape->calculateLocalInertia(mass, inertia);
|
||||
if (!body) {
|
||||
body = new btRigidBody(mass, motionState, shape, inertia);
|
||||
++_numRigidBodies;
|
||||
motionState->setRigidBody(body);
|
||||
} else {
|
||||
body->setMassProps(mass, inertia);
|
||||
|
@ -141,7 +143,6 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) {
|
|||
if (!body) {
|
||||
assert(motionState->getShape());
|
||||
body = new btRigidBody(mass, motionState, const_cast<btCollisionShape*>(motionState->getShape()), inertia);
|
||||
++_numRigidBodies;
|
||||
motionState->setRigidBody(body);
|
||||
} else {
|
||||
body->setMassProps(mass, inertia);
|
||||
|
@ -209,7 +210,6 @@ void PhysicsEngine::removeObjects(const VectorOfMotionStates& objects) {
|
|||
if (body) {
|
||||
removeDynamicsForBody(body);
|
||||
_dynamicsWorld->removeRigidBody(body);
|
||||
--_numRigidBodies;
|
||||
|
||||
// NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it.
|
||||
object->setRigidBody(nullptr);
|
||||
|
@ -227,7 +227,6 @@ void PhysicsEngine::removeSetOfObjects(const SetOfMotionStates& objects) {
|
|||
if (body) {
|
||||
removeDynamicsForBody(body);
|
||||
_dynamicsWorld->removeRigidBody(body);
|
||||
--_numRigidBodies;
|
||||
|
||||
// NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it.
|
||||
object->setRigidBody(nullptr);
|
||||
|
@ -279,7 +278,6 @@ void PhysicsEngine::reinsertObject(ObjectMotionState* object) {
|
|||
btRigidBody* body = object->getRigidBody();
|
||||
if (body) {
|
||||
_dynamicsWorld->removeRigidBody(body);
|
||||
--_numRigidBodies;
|
||||
// add it back
|
||||
addObjectToDynamicsWorld(object);
|
||||
}
|
||||
|
@ -292,7 +290,6 @@ void PhysicsEngine::processTransaction(PhysicsEngine::Transaction& transaction)
|
|||
if (body) {
|
||||
removeDynamicsForBody(body);
|
||||
_dynamicsWorld->removeRigidBody(body);
|
||||
--_numRigidBodies;
|
||||
|
||||
// NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it.
|
||||
object->setRigidBody(nullptr);
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
void init();
|
||||
|
||||
uint32_t getNumSubsteps() const;
|
||||
int32_t getNumCollisionObjects() const;
|
||||
|
||||
void removeObjects(const VectorOfMotionStates& objects);
|
||||
void removeSetOfObjects(const SetOfMotionStates& objects); // only called during teardown
|
||||
|
@ -143,8 +144,6 @@ public:
|
|||
// See PhysicsCollisionGroups.h for mask flags.
|
||||
std::vector<ContactTestResult> contactTest(uint16_t mask, const ShapeInfo& regionShapeInfo, const Transform& regionTransform, uint16_t group = USER_COLLISION_GROUP_DYNAMIC) const;
|
||||
|
||||
int32_t getNumRigidBodies() const { return _numRigidBodies; }
|
||||
|
||||
private:
|
||||
QList<EntityDynamicPointer> removeDynamicsForBody(btRigidBody* body);
|
||||
void addObjectToDynamicsWorld(ObjectMotionState* motionState);
|
||||
|
@ -177,7 +176,6 @@ private:
|
|||
CharacterController* _myAvatarController;
|
||||
|
||||
uint32_t _numContactFrames { 0 };
|
||||
int32_t _numRigidBodies { 0 };
|
||||
|
||||
bool _dumpNextStats { false };
|
||||
bool _saveNextStats { false };
|
||||
|
|
Loading…
Reference in a new issue