mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 15:33:02 +02:00
add 'physics body count' to debug stats
This commit is contained in:
parent
f5cae61b43
commit
777b90bdc0
7 changed files with 29 additions and 1 deletions
|
@ -60,6 +60,9 @@ Item {
|
|||
StatText {
|
||||
text: "Game Rate: " + root.gameLoopRate
|
||||
}
|
||||
StatText {
|
||||
text: "Physics Body Count: " + root.physicsBodyCount
|
||||
}
|
||||
StatText {
|
||||
visible: root.expanded
|
||||
text: root.gameUpdateStats
|
||||
|
|
|
@ -6184,6 +6184,10 @@ bool Application::isHMDMode() const {
|
|||
return getActiveDisplayPlugin()->isHmd();
|
||||
}
|
||||
|
||||
float Application::getNumRigidBodies() const {
|
||||
return _physicsEngine ? _physicsEngine->getNumRigidBodies() : 0;
|
||||
}
|
||||
|
||||
float Application::getTargetRenderFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); }
|
||||
|
||||
QRect Application::getDesirableApplicationGeometry() const {
|
||||
|
|
|
@ -207,6 +207,7 @@ public:
|
|||
|
||||
size_t getRenderFrameCount() const { return _renderFrameCount; }
|
||||
float getRenderLoopRate() const { return _renderLoopCounter.rate(); }
|
||||
float getNumRigidBodies() const;
|
||||
float getTargetRenderFrameRate() const; // frames/second
|
||||
|
||||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
|
|
|
@ -121,6 +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(updatedAvatarCount, avatarManager->getNumAvatarsUpdated());
|
||||
STAT_UPDATE(notUpdatedAvatarCount, avatarManager->getNumAvatarsNotUpdated());
|
||||
STAT_UPDATE(serverCount, (int)nodeList->size());
|
||||
|
|
|
@ -49,6 +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} updatedAvatarCount - <em>Read-only.</em>
|
||||
* @property {number} notUpdatedAvatarCount - <em>Read-only.</em>
|
||||
* @property {number} packetInCount - <em>Read-only.</em>
|
||||
|
@ -195,6 +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, updatedAvatarCount, 0)
|
||||
STATS_PROPERTY(int, notUpdatedAvatarCount, 0)
|
||||
STATS_PROPERTY(int, packetInCount, 0)
|
||||
|
@ -406,6 +408,13 @@ signals:
|
|||
*/
|
||||
void gameLoopRateChanged();
|
||||
|
||||
/**jsdoc
|
||||
* Trigered when
|
||||
* @function Stats.numPhysicsBodiesChanged
|
||||
* @returns {Signal}
|
||||
*/
|
||||
void physicsBodyCountChanged();
|
||||
|
||||
/**jsdoc
|
||||
* Triggered when the value of the <code>avatarCount</code> property changes.
|
||||
* @function Stats.avatarCountChanged
|
||||
|
|
|
@ -93,6 +93,7 @@ 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);
|
||||
|
@ -116,6 +117,7 @@ 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);
|
||||
|
@ -139,6 +141,7 @@ 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);
|
||||
|
@ -206,6 +209,7 @@ 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);
|
||||
|
@ -223,6 +227,7 @@ 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);
|
||||
|
@ -274,6 +279,7 @@ void PhysicsEngine::reinsertObject(ObjectMotionState* object) {
|
|||
btRigidBody* body = object->getRigidBody();
|
||||
if (body) {
|
||||
_dynamicsWorld->removeRigidBody(body);
|
||||
--_numRigidBodies;
|
||||
// add it back
|
||||
addObjectToDynamicsWorld(object);
|
||||
}
|
||||
|
@ -286,6 +292,7 @@ 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);
|
||||
|
|
|
@ -143,6 +143,8 @@ 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);
|
||||
|
@ -174,7 +176,8 @@ private:
|
|||
|
||||
CharacterController* _myAvatarController;
|
||||
|
||||
uint32_t _numContactFrames = 0;
|
||||
uint32_t _numContactFrames { 0 };
|
||||
int32_t _numRigidBodies { 0 };
|
||||
|
||||
bool _dumpNextStats { false };
|
||||
bool _saveNextStats { false };
|
||||
|
|
Loading…
Reference in a new issue