Unified · Split
| @@ -61,7 +61,7 @@ Item { · 60 unmodified lines | |||
| 61 | text: "Game Rate: " + root.gameLoopRate | 61 | text: "Game Rate: " + root.gameLoopRate |
| 62 | } | 62 | } |
| 63 | StatText { | 63 | StatText { |
| 64 | text: "Physics Body Count: " + root.physicsBodyCount | 64 | text: "Physics Object Count: " + root.physicsObjectCount |
| 65 | } | 65 | } |
| 66 | StatText { | 66 | StatText { |
| 67 | visible: root.expanded | 67 | visible: root.expanded |
| @@ -6184,8 +6184,8 @@ bool Application::isHMDMode() const { · 6183 unmodified lines | |||
| 6184 | return getActiveDisplayPlugin()->isHmd(); | 6184 | return getActiveDisplayPlugin()->isHmd(); |
| 6185 | } | 6185 | } |
| 6186 | 6186 | ||
| 6187 | float Application::getNumRigidBodies() const { | 6187 | float Application::getNumCollisionObjects() const { |
| 6188 | return _physicsEngine ? _physicsEngine->getNumRigidBodies() : 0; | 6188 | return _physicsEngine ? _physicsEngine->getNumCollisionObjects() : 0; |
| 6189 | } | 6189 | } |
| 6190 | 6190 | ||
| 6191 | float Application::getTargetRenderFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); } | 6191 | float Application::getTargetRenderFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); } |
| @@ -207,7 +207,7 @@ public: · 206 unmodified lines | |||
| 207 | 207 | ||
| 208 | size_t getRenderFrameCount() const { return _renderFrameCount; } | 208 | size_t getRenderFrameCount() const { return _renderFrameCount; } |
| 209 | float getRenderLoopRate() const { return _renderLoopCounter.rate(); } | 209 | float getRenderLoopRate() const { return _renderLoopCounter.rate(); } |
| 210 | float getNumRigidBodies() const; | 210 | float getNumCollisionObjects() const; |
| 211 | float getTargetRenderFrameRate() const; // frames/second | 211 | float getTargetRenderFrameRate() const; // frames/second |
| 212 | 212 | ||
| 213 | float getFieldOfView() { return _fieldOfView.get(); } | 213 | float getFieldOfView() { return _fieldOfView.get(); } |
| @@ -121,7 +121,7 @@ void Stats::updateStats(bool force) { · 120 unmodified lines | |||
| 121 | auto avatarManager = DependencyManager::get<AvatarManager>(); | 121 | auto avatarManager = DependencyManager::get<AvatarManager>(); |
| 122 | // we need to take one avatar out so we don't include ourselves | 122 | // we need to take one avatar out so we don't include ourselves |
| 123 | STAT_UPDATE(avatarCount, avatarManager->size() - 1); | 123 | STAT_UPDATE(avatarCount, avatarManager->size() - 1); |
| 124 | STAT_UPDATE(physicsBodyCount, qApp->getNumRigidBodies()); | 124 | STAT_UPDATE(physicsObjectCount, qApp->getNumCollisionObjects()); |
| 125 | STAT_UPDATE(updatedAvatarCount, avatarManager->getNumAvatarsUpdated()); | 125 | STAT_UPDATE(updatedAvatarCount, avatarManager->getNumAvatarsUpdated()); |
| 126 | STAT_UPDATE(notUpdatedAvatarCount, avatarManager->getNumAvatarsNotUpdated()); | 126 | STAT_UPDATE(notUpdatedAvatarCount, avatarManager->getNumAvatarsNotUpdated()); |
| 127 | STAT_UPDATE(serverCount, (int)nodeList->size()); | 127 | STAT_UPDATE(serverCount, (int)nodeList->size()); |
| @@ -49,7 +49,7 @@ private: \ · 48 unmodified lines | |||
| 49 | * @property {number} presentdroprate - <em>Read-only.</em> | 49 | * @property {number} presentdroprate - <em>Read-only.</em> |
| 50 | * @property {number} gameLoopRate - <em>Read-only.</em> | 50 | * @property {number} gameLoopRate - <em>Read-only.</em> |
| 51 | * @property {number} avatarCount - <em>Read-only.</em> | 51 | * @property {number} avatarCount - <em>Read-only.</em> |
| 52 | * @property {number} physicsBodyCount - <em>Read-only.</em> | 52 | * @property {number} physicsObjectCount - <em>Read-only.</em> |
| 53 | * @property {number} updatedAvatarCount - <em>Read-only.</em> | 53 | * @property {number} updatedAvatarCount - <em>Read-only.</em> |
| 54 | * @property {number} notUpdatedAvatarCount - <em>Read-only.</em> | 54 | * @property {number} notUpdatedAvatarCount - <em>Read-only.</em> |
| 55 | * @property {number} packetInCount - <em>Read-only.</em> | 55 | * @property {number} packetInCount - <em>Read-only.</em> |
| @@ -196,7 +196,7 @@ class Stats : public QQuickItem { · 140 unmodified lines | |||
| 196 | STATS_PROPERTY(float, presentdroprate, 0) | 196 | STATS_PROPERTY(float, presentdroprate, 0) |
| 197 | STATS_PROPERTY(int, gameLoopRate, 0) | 197 | STATS_PROPERTY(int, gameLoopRate, 0) |
| 198 | STATS_PROPERTY(int, avatarCount, 0) | 198 | STATS_PROPERTY(int, avatarCount, 0) |
| 199 | STATS_PROPERTY(int, physicsBodyCount, 0) | 199 | STATS_PROPERTY(int, physicsObjectCount, 0) |
| 200 | STATS_PROPERTY(int, updatedAvatarCount, 0) | 200 | STATS_PROPERTY(int, updatedAvatarCount, 0) |
| 201 | STATS_PROPERTY(int, notUpdatedAvatarCount, 0) | 201 | STATS_PROPERTY(int, notUpdatedAvatarCount, 0) |
| 202 | STATS_PROPERTY(int, packetInCount, 0) | 202 | STATS_PROPERTY(int, packetInCount, 0) |
| @@ -413,7 +413,7 @@ signals: · 210 unmodified lines | |||
| 413 | * @function Stats.numPhysicsBodiesChanged | 413 | * @function Stats.numPhysicsBodiesChanged |
| 414 | * @returns {Signal} | 414 | * @returns {Signal} |
| 415 | */ | 415 | */ |
| 416 | void physicsBodyCountChanged(); | 416 | void physicsObjectCountChanged(); |
| 417 | 417 | ||
| 418 | /**jsdoc | 418 | /**jsdoc |
| 419 | * Triggered when the value of the <code>avatarCount</code> property changes. | 419 | * Triggered when the value of the <code>avatarCount</code> property changes. |
| @@ -77,6 +77,10 @@ uint32_t PhysicsEngine::getNumSubsteps() const { · 76 unmodified lines | |||
| 77 | return _dynamicsWorld->getNumSubsteps(); | 77 | return _dynamicsWorld->getNumSubsteps(); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | int32_t PhysicsEngine::getNumCollisionObjects() const { | ||
| 81 | return _dynamicsWorld ? _dynamicsWorld->getNumCollisionObjects() : 0; | ||
| 82 | } | ||
| 83 | |||
| 80 | // private | 84 | // private |
| 81 | void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { | 85 | void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { |
| 82 | assert(motionState); | 86 | assert(motionState); |
| @@ -93,7 +97,6 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { · 10 unmodified lines | |||
| 93 | btCollisionShape* shape = const_cast<btCollisionShape*>(motionState->getShape()); | 97 | btCollisionShape* shape = const_cast<btCollisionShape*>(motionState->getShape()); |
| 94 | assert(shape); | 98 | assert(shape); |
| 95 | body = new btRigidBody(mass, motionState, shape, inertia); | 99 | body = new btRigidBody(mass, motionState, shape, inertia); |
| 96 | ++_numRigidBodies; | ||
| 97 | motionState->setRigidBody(body); | 100 | motionState->setRigidBody(body); |
| 98 | } else { | 101 | } else { |
| 99 | body->setMassProps(mass, inertia); | 102 | body->setMassProps(mass, inertia); |
| @@ -117,7 +120,6 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { · 17 unmodified lines | |||
| 117 | shape->calculateLocalInertia(mass, inertia); | 120 | shape->calculateLocalInertia(mass, inertia); |
| 118 | if (!body) { | 121 | if (!body) { |
| 119 | body = new btRigidBody(mass, motionState, shape, inertia); | 122 | body = new btRigidBody(mass, motionState, shape, inertia); |
| 120 | ++_numRigidBodies; | ||
| 121 | motionState->setRigidBody(body); | 123 | motionState->setRigidBody(body); |
| 122 | } else { | 124 | } else { |
| 123 | body->setMassProps(mass, inertia); | 125 | body->setMassProps(mass, inertia); |
| @@ -141,7 +143,6 @@ void PhysicsEngine::addObjectToDynamicsWorld(ObjectMotionState* motionState) { · 17 unmodified lines | |||
| 141 | if (!body) { | 143 | if (!body) { |
| 142 | assert(motionState->getShape()); | 144 | assert(motionState->getShape()); |
| 143 | body = new btRigidBody(mass, motionState, const_cast<btCollisionShape*>(motionState->getShape()), inertia); | 145 | body = new btRigidBody(mass, motionState, const_cast<btCollisionShape*>(motionState->getShape()), inertia); |
| 144 | ++_numRigidBodies; | ||
| 145 | motionState->setRigidBody(body); | 146 | motionState->setRigidBody(body); |
| 146 | } else { | 147 | } else { |
| 147 | body->setMassProps(mass, inertia); | 148 | body->setMassProps(mass, inertia); |
| @@ -209,7 +210,6 @@ void PhysicsEngine::removeObjects(const VectorOfMotionStates& objects) { · 61 unmodified lines | |||
| 209 | if (body) { | 210 | if (body) { |
| 210 | removeDynamicsForBody(body); | 211 | removeDynamicsForBody(body); |
| 211 | _dynamicsWorld->removeRigidBody(body); | 212 | _dynamicsWorld->removeRigidBody(body); |
| 212 | --_numRigidBodies; | ||
| 213 | 213 | ||
| 214 | // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. | 214 | // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. |
| 215 | object->setRigidBody(nullptr); | 215 | object->setRigidBody(nullptr); |
| @@ -227,7 +227,6 @@ void PhysicsEngine::removeSetOfObjects(const SetOfMotionStates& objects) { · 11 unmodified lines | |||
| 227 | if (body) { | 227 | if (body) { |
| 228 | removeDynamicsForBody(body); | 228 | removeDynamicsForBody(body); |
| 229 | _dynamicsWorld->removeRigidBody(body); | 229 | _dynamicsWorld->removeRigidBody(body); |
| 230 | --_numRigidBodies; | ||
| 231 | 230 | ||
| 232 | // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. | 231 | // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. |
| 233 | object->setRigidBody(nullptr); | 232 | object->setRigidBody(nullptr); |
| @@ -279,7 +278,6 @@ void PhysicsEngine::reinsertObject(ObjectMotionState* object) { · 45 unmodified lines | |||
| 279 | btRigidBody* body = object->getRigidBody(); | 278 | btRigidBody* body = object->getRigidBody(); |
| 280 | if (body) { | 279 | if (body) { |
| 281 | _dynamicsWorld->removeRigidBody(body); | 280 | _dynamicsWorld->removeRigidBody(body); |
| 282 | --_numRigidBodies; | ||
| 283 | // add it back | 281 | // add it back |
| 284 | addObjectToDynamicsWorld(object); | 282 | addObjectToDynamicsWorld(object); |
| 285 | } | 283 | } |
| @@ -292,7 +290,6 @@ void PhysicsEngine::processTransaction(PhysicsEngine::Transaction& transaction) · 6 unmodified lines | |||
| 292 | if (body) { | 290 | if (body) { |
| 293 | removeDynamicsForBody(body); | 291 | removeDynamicsForBody(body); |
| 294 | _dynamicsWorld->removeRigidBody(body); | 292 | _dynamicsWorld->removeRigidBody(body); |
| 295 | --_numRigidBodies; | ||
| 296 | 293 | ||
| 297 | // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. | 294 | // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. |
| 298 | object->setRigidBody(nullptr); | 295 | object->setRigidBody(nullptr); |
| @@ -87,6 +87,7 @@ public: · 86 unmodified lines | |||
| 87 | void init(); | 87 | void init(); |
| 88 | 88 | ||
| 89 | uint32_t getNumSubsteps() const; | 89 | uint32_t getNumSubsteps() const; |
| 90 | int32_t getNumCollisionObjects() const; | ||
| 90 | 91 | ||
| 91 | void removeObjects(const VectorOfMotionStates& objects); | 92 | void removeObjects(const VectorOfMotionStates& objects); |
| 92 | void removeSetOfObjects(const SetOfMotionStates& objects); // only called during teardown | 93 | void removeSetOfObjects(const SetOfMotionStates& objects); // only called during teardown |
| @@ -143,8 +144,6 @@ public: · 50 unmodified lines | |||
| 143 | // See PhysicsCollisionGroups.h for mask flags. | 144 | // See PhysicsCollisionGroups.h for mask flags. |
| 144 | std::vector<ContactTestResult> contactTest(uint16_t mask, const ShapeInfo& regionShapeInfo, const Transform& regionTransform, uint16_t group = USER_COLLISION_GROUP_DYNAMIC) const; | 145 | std::vector<ContactTestResult> contactTest(uint16_t mask, const ShapeInfo& regionShapeInfo, const Transform& regionTransform, uint16_t group = USER_COLLISION_GROUP_DYNAMIC) const; |
| 145 | 146 | ||
| 146 | int32_t getNumRigidBodies() const { return _numRigidBodies; } | ||
| 147 | |||
| 148 | private: | 147 | private: |
| 149 | QList<EntityDynamicPointer> removeDynamicsForBody(btRigidBody* body); | 148 | QList<EntityDynamicPointer> removeDynamicsForBody(btRigidBody* body); |
| 150 | void addObjectToDynamicsWorld(ObjectMotionState* motionState); | 149 | void addObjectToDynamicsWorld(ObjectMotionState* motionState); |
| @@ -177,7 +176,6 @@ private: · 26 unmodified lines | |||
| 177 | CharacterController* _myAvatarController; | 176 | CharacterController* _myAvatarController; |
| 178 | 177 | ||
| 179 | uint32_t _numContactFrames { 0 }; | 178 | uint32_t _numContactFrames { 0 }; |
| 180 | int32_t _numRigidBodies { 0 }; | ||
| 181 | 179 | ||
| 182 | bool _dumpNextStats { false }; | 180 | bool _dumpNextStats { false }; |
| 183 | bool _saveNextStats { false }; | 181 | bool _saveNextStats { false }; |