Program Listing for include/PxSimulationStatistics.h

↰ Return to documentation for include/PxSimulationStatistics.h

// 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 NVIDIA CORPORATION 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 ''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.
//
// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.

#ifndef PX_SIMULATION_STATISTICS_H
#define PX_SIMULATION_STATISTICS_H

#include "foundation/PxAssert.h"
#include "PxPhysXConfig.h"
#include "geometry/PxGeometry.h"

#if !PX_DOXYGEN
namespace physx
{
#endif

class PxSimulationStatistics
{
public:

    enum RbPairStatsType
    {
        eDISCRETE_CONTACT_PAIRS,

        eCCD_PAIRS,

        eMODIFIED_CONTACT_PAIRS,

        eTRIGGER_PAIRS
    };


//objects:
    PxU32   nbActiveConstraints;

    PxU32   nbActiveDynamicBodies;

    PxU32   nbActiveKinematicBodies;

    PxU32   nbStaticBodies;

    PxU32   nbDynamicBodies;

    PxU32   nbKinematicBodies;

    PxU32   nbShapes[PxGeometryType::eGEOMETRY_COUNT];

    PxU32   nbAggregates;

    PxU32   nbArticulations;

//solver:
    PxU32   nbAxisSolverConstraints;

    PxU32   compressedContactSize;

    PxU32   requiredContactConstraintMemory;

    PxU32   peakConstraintMemory;

//broadphase:
    PX_FORCE_INLINE PxU32 getNbBroadPhaseAdds() const
    {
        return nbBroadPhaseAdds;
    }

    PX_FORCE_INLINE PxU32 getNbBroadPhaseRemoves() const
    {
        return nbBroadPhaseRemoves;
    }

//collisions:
    PxU32 getRbPairStats(RbPairStatsType pairType, PxGeometryType::Enum g0, PxGeometryType::Enum g1) const
    {
        PX_ASSERT_WITH_MESSAGE( (pairType >= eDISCRETE_CONTACT_PAIRS) &&
                                (pairType <= eTRIGGER_PAIRS),
                                "Invalid pairType in PxSimulationStatistics::getRbPairStats");

        if (g0 >= PxGeometryType::eGEOMETRY_COUNT || g1 >= PxGeometryType::eGEOMETRY_COUNT)
        {
            PX_ASSERT(false);
            return 0;
        }

        PxU32 nbPairs = 0;
        switch(pairType)
        {
            case eDISCRETE_CONTACT_PAIRS:
                nbPairs = nbDiscreteContactPairs[g0][g1];
                break;
            case eCCD_PAIRS:
                nbPairs = nbCCDPairs[g0][g1];
                break;
            case eMODIFIED_CONTACT_PAIRS:
                nbPairs = nbModifiedContactPairs[g0][g1];
                break;
            case eTRIGGER_PAIRS:
                nbPairs = nbTriggerPairs[g0][g1];
                break;
        }
        return nbPairs;
    }

    PxU32   nbDiscreteContactPairsTotal;

    PxU32   nbDiscreteContactPairsWithCacheHits;

    PxU32   nbDiscreteContactPairsWithContacts;

    PxU32   nbNewPairs;

    PxU32   nbLostPairs;

    PxU32   nbNewTouches;

    PxU32   nbLostTouches;

    PxU32   nbPartitions;

    PxU64   gpuMemParticles;

    PxU64   gpuMemSoftBodies;

    PxU64   gpuMemFEMCloths;

    PxU64   gpuMemHairSystems;

    PxU64   gpuMemHeap;

    PxU64   gpuMemHeapBroadPhase;

    PxU64   gpuMemHeapNarrowPhase;

    PxU64   gpuMemHeapSolver;

    PxU64   gpuMemHeapArticulation;

    PxU64   gpuMemHeapSimulation;

    PxU64   gpuMemHeapSimulationArticulation;

    PxU64   gpuMemHeapSimulationParticles;

    PxU64   gpuMemHeapSimulationSoftBody;

    PxU64   gpuMemHeapSimulationFEMCloth;

    PxU64   gpuMemHeapSimulationHairSystem;

    PxU64   gpuMemHeapParticles;

    PxU64   gpuMemHeapSoftBodies;

    PxU64   gpuMemHeapFEMCloths;

    PxU64   gpuMemHeapHairSystems;

    PxU64   gpuMemHeapOther;

    PxSimulationStatistics() :
        nbActiveConstraints                 (0),
        nbActiveDynamicBodies               (0),
        nbActiveKinematicBodies             (0),
        nbStaticBodies                      (0),
        nbDynamicBodies                     (0),
        nbKinematicBodies                   (0),
        nbAggregates                        (0),
        nbArticulations                     (0),
        nbAxisSolverConstraints             (0),
        compressedContactSize               (0),
        requiredContactConstraintMemory     (0),
        peakConstraintMemory                (0),
        nbDiscreteContactPairsTotal         (0),
        nbDiscreteContactPairsWithCacheHits (0),
        nbDiscreteContactPairsWithContacts  (0),
        nbNewPairs                          (0),
        nbLostPairs                         (0),
        nbNewTouches                        (0),
        nbLostTouches                       (0),
        nbPartitions                        (0),
        gpuMemParticles                     (0),
        gpuMemSoftBodies                    (0),
        gpuMemFEMCloths                     (0),
        gpuMemHairSystems                   (0),
        gpuMemHeap                          (0),
        gpuMemHeapBroadPhase                (0),
        gpuMemHeapNarrowPhase               (0),
        gpuMemHeapSolver                    (0),
        gpuMemHeapArticulation              (0),
        gpuMemHeapSimulation                (0),
        gpuMemHeapSimulationArticulation    (0),
        gpuMemHeapSimulationParticles       (0),
        gpuMemHeapSimulationSoftBody        (0),
        gpuMemHeapSimulationFEMCloth        (0),
        gpuMemHeapSimulationHairSystem      (0),
        gpuMemHeapParticles                 (0),
        gpuMemHeapSoftBodies                (0),
        gpuMemHeapFEMCloths                 (0),
        gpuMemHeapHairSystems               (0),
        gpuMemHeapOther                     (0)
    {
        nbBroadPhaseAdds = 0;
        nbBroadPhaseRemoves = 0;

        for(PxU32 i=0; i < PxGeometryType::eGEOMETRY_COUNT; i++)
        {
            for(PxU32 j=0; j < PxGeometryType::eGEOMETRY_COUNT; j++)
            {
                nbDiscreteContactPairs[i][j] = 0;
                nbModifiedContactPairs[i][j] = 0;
                nbCCDPairs[i][j] = 0;
                nbTriggerPairs[i][j] = 0;
            }
        }

        for(PxU32 i=0; i < PxGeometryType::eGEOMETRY_COUNT; i++)
        {
            nbShapes[i] = 0;
        }
    }


    //
    // We advise to not access these members directly. Use the provided accessor methods instead.
    //
//broadphase:
    PxU32   nbBroadPhaseAdds;
    PxU32   nbBroadPhaseRemoves;

//collisions:
    PxU32   nbDiscreteContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
    PxU32   nbCCDPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
    PxU32   nbModifiedContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
    PxU32   nbTriggerPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
};

#if !PX_DOXYGEN
} // namespace physx
#endif

#endif