This commit is contained in:
2025-11-28 23:13:44 +05:30
commit a3a8e79709
7360 changed files with 1156074 additions and 0 deletions

View File

@ -0,0 +1,83 @@
//
// 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-2021 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 PXPVDSDK_PSPVD_H
#define PXPVDSDK_PSPVD_H
/** \addtogroup pvd
@{
*/
#include "pvd/PxPvd.h"
#include "PsBroadcast.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxPvdTransport;
#if !PX_DOXYGEN
namespace pvdsdk
{
#endif
class PvdDataStream;
class PvdClient;
class PvdOMMetaDataProvider;
// PsPvd is used for advanced user, it support custom pvd client API
class PsPvd : public physx::PxPvd, public shdfnd::AllocationListener
{
public:
virtual void addClient(PvdClient* client) = 0;
virtual void removeClient(PvdClient* client) = 0;
virtual bool registerObject(const void* inItem) = 0;
virtual bool unRegisterObject(const void* inItem) = 0;
//AllocationListener
void onAllocation(size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory) = 0;
void onDeallocation(void* addr) = 0;
virtual PvdOMMetaDataProvider& getMetaDataProvider() = 0;
virtual uint64_t getNextStreamId() = 0;
// Call to flush events to PVD
virtual void flush() = 0;
};
#if !PX_DOXYGEN
} // namespace pvdsdk
} // namespace physx
#endif
/** @} */
#endif // PXPVDSDK_PSPVD_H

View File

@ -0,0 +1,231 @@
//
// 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-2021 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 PXPVDSDK_PXPROFILEALLOCATORWRAPPER_H
#define PXPVDSDK_PXPROFILEALLOCATORWRAPPER_H
#include "foundation/PxPreprocessor.h"
#include "foundation/PxAllocatorCallback.h"
#include "foundation/PxErrorCallback.h"
#include "foundation/PxAssert.h"
#include "PsArray.h"
#include "PsHashMap.h"
namespace physx { namespace profile {
/**
\brief Helper struct to encapsulate the user allocator callback
Useful for array and hash templates
*/
struct PxProfileAllocatorWrapper
{
PxAllocatorCallback* mUserAllocator;
PxProfileAllocatorWrapper( PxAllocatorCallback& inUserAllocator )
: mUserAllocator( &inUserAllocator )
{
}
PxProfileAllocatorWrapper( PxAllocatorCallback* inUserAllocator )
: mUserAllocator( inUserAllocator )
{
}
PxAllocatorCallback& getAllocator() const
{
PX_ASSERT( NULL != mUserAllocator );
return *mUserAllocator;
}
};
/**
\brief Helper class to encapsulate the reflection allocator
*/
template <typename T>
class PxProfileWrapperReflectionAllocator
{
static const char* getName()
{
#if PX_LINUX || PX_ANDROID || PX_PS4 || PX_IOS || PX_OSX || PX_EMSCRIPTEN || PX_SWITCH
return __PRETTY_FUNCTION__;
#else
return typeid(T).name();
#endif
}
PxProfileAllocatorWrapper* mWrapper;
public:
PxProfileWrapperReflectionAllocator(PxProfileAllocatorWrapper& inWrapper) : mWrapper( &inWrapper ) {}
PxProfileWrapperReflectionAllocator( const PxProfileWrapperReflectionAllocator& inOther )
: mWrapper( inOther.mWrapper )
{
}
PxProfileWrapperReflectionAllocator& operator=( const PxProfileWrapperReflectionAllocator& inOther )
{
mWrapper = inOther.mWrapper;
return *this;
}
PxAllocatorCallback& getAllocator() { return mWrapper->getAllocator(); }
void* allocate(size_t size, const char* filename, int line)
{
#if PX_CHECKED // checked and debug builds
if(!size)
return 0;
return getAllocator().allocate(size, getName(), filename, line);
#else
return getAllocator().allocate(size, "<no allocation names in this config>", filename, line);
#endif
}
void deallocate(void* ptr)
{
if(ptr)
getAllocator().deallocate(ptr);
}
};
/**
\brief Helper class to encapsulate the named allocator
*/
struct PxProfileWrapperNamedAllocator
{
PxProfileAllocatorWrapper* mWrapper;
const char* mAllocationName;
PxProfileWrapperNamedAllocator(PxProfileAllocatorWrapper& inWrapper, const char* inAllocationName)
: mWrapper( &inWrapper )
, mAllocationName( inAllocationName )
{}
PxProfileWrapperNamedAllocator( const PxProfileWrapperNamedAllocator& inOther )
: mWrapper( inOther.mWrapper )
, mAllocationName( inOther.mAllocationName )
{
}
PxProfileWrapperNamedAllocator& operator=( const PxProfileWrapperNamedAllocator& inOther )
{
mWrapper = inOther.mWrapper;
mAllocationName = inOther.mAllocationName;
return *this;
}
PxAllocatorCallback& getAllocator() { return mWrapper->getAllocator(); }
void* allocate(size_t size, const char* filename, int line)
{
if(!size)
return 0;
return getAllocator().allocate(size, mAllocationName, filename, line);
}
void deallocate(void* ptr)
{
if(ptr)
getAllocator().deallocate(ptr);
}
};
/**
\brief Helper struct to encapsulate the array
*/
template<class T>
struct PxProfileArray : public shdfnd::Array<T, PxProfileWrapperReflectionAllocator<T> >
{
typedef PxProfileWrapperReflectionAllocator<T> TAllocatorType;
PxProfileArray( PxProfileAllocatorWrapper& inWrapper )
: shdfnd::Array<T, TAllocatorType >( TAllocatorType( inWrapper ) )
{
}
PxProfileArray( const PxProfileArray< T >& inOther )
: shdfnd::Array<T, TAllocatorType >( inOther, inOther )
{
}
};
/**
\brief Helper struct to encapsulate the array
*/
template<typename TKeyType, typename TValueType, typename THashType=shdfnd::Hash<TKeyType> >
struct PxProfileHashMap : public shdfnd::HashMap<TKeyType, TValueType, THashType, PxProfileWrapperReflectionAllocator< TValueType > >
{
typedef shdfnd::HashMap<TKeyType, TValueType, THashType, PxProfileWrapperReflectionAllocator< TValueType > > THashMapType;
typedef PxProfileWrapperReflectionAllocator<TValueType> TAllocatorType;
PxProfileHashMap( PxProfileAllocatorWrapper& inWrapper )
: THashMapType( TAllocatorType( inWrapper ) )
{
}
};
/**
\brief Helper function to encapsulate the profile allocation
*/
template<typename TDataType>
inline TDataType* PxProfileAllocate( PxAllocatorCallback* inAllocator, const char* file, int inLine )
{
PxProfileAllocatorWrapper wrapper( inAllocator );
typedef PxProfileWrapperReflectionAllocator< TDataType > TAllocator;
TAllocator theAllocator( wrapper );
return reinterpret_cast<TDataType*>( theAllocator.allocate( sizeof( TDataType ), file, inLine ) );
}
/**
\brief Helper function to encapsulate the profile allocation
*/
template<typename TDataType>
inline TDataType* PxProfileAllocate( PxAllocatorCallback& inAllocator, const char* file, int inLine )
{
return PxProfileAllocate<TDataType>( &inAllocator, file, inLine );
}
/**
\brief Helper function to encapsulate the profile deallocation
*/
template<typename TDataType>
inline void PxProfileDeleteAndDeallocate( PxProfileAllocatorWrapper& inAllocator, TDataType* inDType )
{
PX_ASSERT(inDType);
PxAllocatorCallback& allocator( inAllocator.getAllocator() );
inDType->~TDataType();
allocator.deallocate( inDType );
}
/**
\brief Helper function to encapsulate the profile deallocation
*/
template<typename TDataType>
inline void PxProfileDeleteAndDeallocate( PxAllocatorCallback& inAllocator, TDataType* inDType )
{
PxProfileAllocatorWrapper wrapper( &inAllocator );
PxProfileDeleteAndDeallocate( wrapper, inDType );
}
} }
#define PX_PROFILE_NEW( allocator, dtype ) new (physx::profile::PxProfileAllocate<dtype>( allocator, __FILE__, __LINE__ )) dtype
#define PX_PROFILE_DELETE( allocator, obj ) physx::profile::PxProfileDeleteAndDeallocate( allocator, obj );
#endif // PXPVDSDK_PXPROFILEALLOCATORWRAPPER_H

View File

@ -0,0 +1,76 @@
//
// 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-2021 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 PXPVDSDK_PXPVDCLIENT_H
#define PXPVDSDK_PXPVDCLIENT_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxFlags.h"
#include "foundation/PxVec3.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
class PvdDataStream;
class PvdUserRenderer;
/**
\brief PvdClient is the per-client connection to PVD.
It provides callback when PVD is connected/disconnted.
It provides access to the internal object so that advanced users can create extension client.
*/
class PvdClient
{
public:
virtual PvdDataStream* getDataStream() = 0;
virtual bool isConnected() const = 0;
virtual void onPvdConnected() = 0;
virtual void onPvdDisconnected() = 0;
virtual void flush() = 0;
protected:
virtual ~PvdClient()
{
}
};
#if !PX_DOXYGEN
} // namespace pvdsdk
} // namespace physx
#endif
/** @} */
#endif // PXPVDSDK_PXPVDCLIENT_H

View File

@ -0,0 +1,272 @@
//
// 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-2021 NVIDIA Corporation. All rights reserved.
#ifndef PXPVDSDK_PXPVDDATASTREAM_H
#define PXPVDSDK_PXPVDDATASTREAM_H
/** \addtogroup pvd
@{
*/
#include "pvd/PxPvd.h"
#include "PxPvdErrorCodes.h"
#include "PxPvdObjectModelBaseTypes.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
class PvdPropertyDefinitionHelper;
class PvdMetaDataStream
{
protected:
virtual ~PvdMetaDataStream()
{
}
public:
virtual PvdError createClass(const NamespacedName& nm) = 0;
template <typename TDataType>
PvdError createClass()
{
return createClass(getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError deriveClass(const NamespacedName& parent, const NamespacedName& child) = 0;
template <typename TParentType, typename TChildType>
PvdError deriveClass()
{
return deriveClass(getPvdNamespacedNameForType<TParentType>(), getPvdNamespacedNameForType<TChildType>());
}
virtual bool isClassExist(const NamespacedName& nm) = 0;
template <typename TDataType>
bool isClassExist()
{
return isClassExist(getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError createProperty(const NamespacedName& clsName, const char* name, const char* semantic,
const NamespacedName& dtypeName, PropertyType::Enum propertyType,
DataRef<NamedValue> values = DataRef<NamedValue>()) = 0;
template <typename TClsType, typename TDataType>
PvdError createProperty(String name, String semantic = "", PropertyType::Enum propertyType = PropertyType::Scalar,
DataRef<NamedValue> values = DataRef<NamedValue>())
{
return createProperty(getPvdNamespacedNameForType<TClsType>(), name, semantic,
getPvdNamespacedNameForType<TDataType>(), propertyType, values);
}
virtual PvdError createPropertyMessage(const NamespacedName& cls, const NamespacedName& msgName,
DataRef<PropertyMessageArg> entries, uint32_t messageSizeInBytes) = 0;
template <typename TClsType, typename TMsgType>
PvdError createPropertyMessage(DataRef<PropertyMessageArg> entries)
{
return createPropertyMessage(getPvdNamespacedNameForType<TClsType>(), getPvdNamespacedNameForType<TMsgType>(),
entries, sizeof(TMsgType));
}
};
class PvdInstanceDataStream
{
protected:
virtual ~PvdInstanceDataStream()
{
}
public:
virtual PvdError createInstance(const NamespacedName& cls, const void* instance) = 0;
template <typename TDataType>
PvdError createInstance(const TDataType* inst)
{
return createInstance(getPvdNamespacedNameForType<TDataType>(), inst);
}
virtual bool isInstanceValid(const void* instance) = 0;
// If the property will fit or is already completely in memory
virtual PvdError setPropertyValue(const void* instance, String name, DataRef<const uint8_t> data,
const NamespacedName& incomingTypeName) = 0;
template <typename TDataType>
PvdError setPropertyValue(const void* instance, String name, const TDataType& value)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(&value);
return setPropertyValue(instance, name, DataRef<const uint8_t>(dataStart, dataStart + sizeof(TDataType)),
getPvdNamespacedNameForType<TDataType>());
}
template <typename TDataType>
PvdError setPropertyValue(const void* instance, String name, const TDataType* value, uint32_t numItems)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(value);
return setPropertyValue(instance, name,
DataRef<const uint8_t>(dataStart, dataStart + sizeof(TDataType) * numItems),
getPvdNamespacedNameForType<TDataType>());
}
// Else if the property is very large (contact reports) you can send it in chunks.
virtual PvdError beginSetPropertyValue(const void* instance, String name, const NamespacedName& incomingTypeName) = 0;
template <typename TDataType>
PvdError beginSetPropertyValue(const void* instance, String name)
{
return beginSetPropertyValue(instance, name, getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError appendPropertyValueData(DataRef<const uint8_t> data) = 0;
template <typename TDataType>
PvdError appendPropertyValueData(const TDataType* value, uint32_t numItems)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(value);
return appendPropertyValueData(DataRef<const uint8_t>(dataStart, dataStart + numItems * sizeof(TDataType)));
}
virtual PvdError endSetPropertyValue() = 0;
// Set a set of properties to various values on an object.
virtual PvdError setPropertyMessage(const void* instance, const NamespacedName& msgName,
DataRef<const uint8_t> data) = 0;
template <typename TDataType>
PvdError setPropertyMessage(const void* instance, const TDataType& value)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(&value);
return setPropertyMessage(instance, getPvdNamespacedNameForType<TDataType>(),
DataRef<const uint8_t>(dataStart, sizeof(TDataType)));
}
// If you need to send of lot of identical messages, this avoids a hashtable lookup per message.
virtual PvdError beginPropertyMessageGroup(const NamespacedName& msgName) = 0;
template <typename TDataType>
PvdError beginPropertyMessageGroup()
{
return beginPropertyMessageGroup(getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError sendPropertyMessageFromGroup(const void* instance, DataRef<const uint8_t> data) = 0;
template <typename TDataType>
PvdError sendPropertyMessageFromGroup(const void* instance, const TDataType& value)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(&value);
return sendPropertyMessageFromGroup(instance, DataRef<const uint8_t>(dataStart, sizeof(TDataType)));
}
virtual PvdError endPropertyMessageGroup() = 0;
// These functions ensure the target array doesn't contain duplicates
virtual PvdError pushBackObjectRef(const void* instId, String propName, const void* objRef) = 0;
virtual PvdError removeObjectRef(const void* instId, String propName, const void* objRef) = 0;
// Instance elimination.
virtual PvdError destroyInstance(const void* key) = 0;
// Profiling hooks
virtual PvdError beginSection(const void* instance, String name) = 0;
virtual PvdError endSection(const void* instance, String name) = 0;
// Origin Shift
virtual PvdError originShift(const void* scene, PxVec3 shift) = 0;
public:
/*For some cases, pvd command cannot be run immediately. For example, when create joints, while the actors may still
*pending for insert, the joints update commands can be run deffered.
*/
class PvdCommand
{
public:
// Assigned is needed for copying
PvdCommand(const PvdCommand&)
{
}
PvdCommand& operator=(const PvdCommand&)
{
return *this;
}
public:
PvdCommand()
{
}
virtual ~PvdCommand()
{
}
// Not pure virtual so can have default PvdCommand obj
virtual bool canRun(PvdInstanceDataStream&)
{
return false;
}
virtual void run(PvdInstanceDataStream&)
{
}
};
// PVD SDK provide this helper function to allocate cmd's memory and release them at after flush the command queue
virtual void* allocateMemForCmd(uint32_t length) = 0;
// PVD will call the destructor of PvdCommand object at the end fo flushPvdCommand
virtual void pushPvdCommand(PvdCommand& cmd) = 0;
virtual void flushPvdCommand() = 0;
};
class PvdDataStream : public PvdInstanceDataStream, public PvdMetaDataStream
{
protected:
virtual ~PvdDataStream()
{
}
public:
virtual void release() = 0;
virtual bool isConnected() = 0;
virtual void addProfileZone(void* zone, const char* name) = 0;
virtual void addProfileZoneEvent(void* zone, const char* name, uint16_t eventId, bool compileTimeEnabled) = 0;
virtual PvdPropertyDefinitionHelper& getPropertyDefinitionHelper() = 0;
virtual void setIsTopLevelUIElement(const void* instance, bool topLevel) = 0;
virtual void sendErrorMessage(uint32_t code, const char* message, const char* file, uint32_t line) = 0;
virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target) = 0;
/**
\brief Create a new PvdDataStream.
\param pvd A pointer to a valid PxPvd instance. This must be non-null.
*/
static PvdDataStream* create(PxPvd* pvd);
};
#if !PX_DOXYGEN
} // pvdsdk
} // physx
#endif
/** @} */
#endif // PXPVDSDK_PXPVDDATASTREAM_H

View File

@ -0,0 +1,120 @@
//
// 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-2021 NVIDIA Corporation. All rights reserved.
#ifndef PXPVDSDK_PXPVDDATASTREAMHELPERS_H
#define PXPVDSDK_PXPVDDATASTREAMHELPERS_H
/** \addtogroup pvd
@{
*/
#include "PxPvdObjectModelBaseTypes.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
class PvdPropertyDefinitionHelper
{
protected:
virtual ~PvdPropertyDefinitionHelper()
{
}
public:
/**
Push a name c such that it appends such as a.b.c.
*/
virtual void pushName(const char* inName, const char* inAppendStr = ".") = 0;
/**
Push a name c such that it appends like a.b[c]
*/
virtual void pushBracketedName(const char* inName, const char* leftBracket = "[", const char* rightBracket = "]") = 0;
/**
* Pop the current name
*/
virtual void popName() = 0;
virtual void clearNameStack() = 0;
/**
* Get the current name at the top of the name stack.
* Would return "a.b.c" or "a.b[c]" in the above examples.
*/
virtual const char* getTopName() = 0;
virtual void addNamedValue(const char* name, uint32_t value) = 0;
virtual void clearNamedValues() = 0;
virtual DataRef<NamedValue> getNamedValues() = 0;
/**
* Define a property using the top of the name stack and the passed-in semantic
*/
virtual void createProperty(const NamespacedName& clsName, const char* inSemantic, const NamespacedName& dtypeName,
PropertyType::Enum propType = PropertyType::Scalar) = 0;
template <typename TClsType, typename TDataType>
void createProperty(const char* inSemantic = "", PropertyType::Enum propType = PropertyType::Scalar)
{
createProperty(getPvdNamespacedNameForType<TClsType>(), inSemantic, getPvdNamespacedNameForType<TDataType>(),
propType);
}
// The datatype used for instances needs to be pointer unless you actually have pvdsdk::InstanceId members on your
// value structs.
virtual void addPropertyMessageArg(const NamespacedName& inDatatype, uint32_t inOffset, uint32_t inSize) = 0;
template <typename TDataType>
void addPropertyMessageArg(uint32_t offset)
{
addPropertyMessageArg(getPvdNamespacedNameForType<TDataType>(), offset, static_cast<uint32_t>(sizeof(TDataType)));
}
virtual void addPropertyMessage(const NamespacedName& clsName, const NamespacedName& msgName,
uint32_t inStructSizeInBytes) = 0;
template <typename TClsType, typename TMsgType>
void addPropertyMessage()
{
addPropertyMessage(getPvdNamespacedNameForType<TClsType>(), getPvdNamespacedNameForType<TMsgType>(),
static_cast<uint32_t>(sizeof(TMsgType)));
}
virtual void clearPropertyMessageArgs() = 0;
void clearBufferedData()
{
clearNameStack();
clearPropertyMessageArgs();
clearNamedValues();
}
};
#if !PX_DOXYGEN
} // pvdsdk
} // physx
#endif
/** @} */
#endif // PXPVDSDK_PXPVDDATASTREAMHELPERS_H

View File

@ -0,0 +1,62 @@
//
// 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-2021 NVIDIA Corporation. All rights reserved.
#ifndef PXPVDSDK_PXPVDERRORCODES_H
#define PXPVDSDK_PXPVDERRORCODES_H
/** \addtogroup pvd
@{
*/
#include "foundation/Px.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
struct PvdErrorType
{
enum Enum
{
Success = 0,
NetworkError,
ArgumentError,
Disconnect,
InternalProblem
};
};
typedef PvdErrorType::Enum PvdError;
#if !PX_DOXYGEN
}
}
#endif
/** @} */
#endif // PXPVDSDK_PXPVDERRORCODES_H

View File

@ -0,0 +1,428 @@
//
// 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-2021 NVIDIA Corporation. All rights reserved.
#ifndef PXPVDSDK_PXPVDOBJECTMODELBASETYPES_H
#define PXPVDSDK_PXPVDOBJECTMODELBASETYPES_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxAssert.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
using namespace physx;
inline const char* nonNull(const char* str)
{
return str ? str : "";
}
// strcmp will crash if passed a null string, however,
// so we need to make sure that doesn't happen. We do that
// by equating NULL and the empty string, "".
inline bool safeStrEq(const char* lhs, const char* rhs)
{
return ::strcmp(nonNull(lhs), nonNull(rhs)) == 0;
}
// Does this string have useful information in it.
inline bool isMeaningful(const char* str)
{
return *(nonNull(str)) > 0;
}
inline uint32_t safeStrLen(const char* str)
{
str = nonNull(str);
return static_cast<uint32_t>(strlen(str));
}
struct ObjectRef
{
int32_t mInstanceId;
ObjectRef(int32_t iid = -1) : mInstanceId(iid)
{
}
operator int32_t() const
{
return mInstanceId;
}
bool hasValue() const
{
return mInstanceId > 0;
}
};
struct U32Array4
{
uint32_t mD0;
uint32_t mD1;
uint32_t mD2;
uint32_t mD3;
U32Array4(uint32_t d0, uint32_t d1, uint32_t d2, uint32_t d3) : mD0(d0), mD1(d1), mD2(d2), mD3(d3)
{
}
U32Array4() : mD0(0), mD1(0), mD2(0), mD3(0)
{
}
};
typedef bool PvdBool;
typedef const char* String;
typedef void* VoidPtr;
typedef double PvdF64;
typedef float PvdF32;
typedef int64_t PvdI64;
typedef uint64_t PvdU64;
typedef int32_t PvdI32;
typedef uint32_t PvdU32;
typedef int16_t PvdI16;
typedef uint16_t PvdU16;
typedef int8_t PvdI8;
typedef uint8_t PvdU8;
struct PvdColor
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
PvdColor(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255) : r(_r), g(_g), b(_b), a(_a)
{
}
PvdColor() : r(0), g(0), b(0), a(255)
{
}
PvdColor(uint32_t abgr)
{
uint8_t* valPtr = reinterpret_cast<uint8_t*>(&abgr);
r = valPtr[0];
g = valPtr[1];
b = valPtr[2];
a = valPtr[3];
}
};
struct StringHandle
{
uint32_t mHandle;
StringHandle(uint32_t val = 0) : mHandle(val)
{
}
operator uint32_t() const
{
return mHandle;
}
};
#define DECLARE_TYPES \
DECLARE_BASE_PVD_TYPE(PvdI8) \
DECLARE_BASE_PVD_TYPE(PvdU8) \
DECLARE_BASE_PVD_TYPE(PvdI16) \
DECLARE_BASE_PVD_TYPE(PvdU16) \
DECLARE_BASE_PVD_TYPE(PvdI32) \
DECLARE_BASE_PVD_TYPE(PvdU32) \
DECLARE_BASE_PVD_TYPE(PvdI64) \
DECLARE_BASE_PVD_TYPE(PvdU64) \
DECLARE_BASE_PVD_TYPE(PvdF32) \
DECLARE_BASE_PVD_TYPE(PvdF64) \
DECLARE_BASE_PVD_TYPE(PvdBool) \
DECLARE_BASE_PVD_TYPE(PvdColor) \
DECLARE_BASE_PVD_TYPE(String) \
DECLARE_BASE_PVD_TYPE(StringHandle) \
DECLARE_BASE_PVD_TYPE(ObjectRef) \
DECLARE_BASE_PVD_TYPE(VoidPtr) \
DECLARE_BASE_PVD_TYPE(PxVec2) \
DECLARE_BASE_PVD_TYPE(PxVec3) \
DECLARE_BASE_PVD_TYPE(PxVec4) \
DECLARE_BASE_PVD_TYPE(PxBounds3) \
DECLARE_BASE_PVD_TYPE(PxQuat) \
DECLARE_BASE_PVD_TYPE(PxTransform) \
DECLARE_BASE_PVD_TYPE(PxMat33) \
DECLARE_BASE_PVD_TYPE(PxMat44) \
DECLARE_BASE_PVD_TYPE(U32Array4)
struct PvdBaseType
{
enum Enum
{
None = 0,
InternalStart = 1,
InternalStop = 64,
#define DECLARE_BASE_PVD_TYPE(type) type,
DECLARE_TYPES
Last
#undef DECLARE_BASE_PVD_TYPE
};
};
struct NamespacedName
{
String mNamespace;
String mName;
NamespacedName(String ns, String nm) : mNamespace(ns), mName(nm)
{
}
NamespacedName(String nm = "") : mNamespace(""), mName(nm)
{
}
bool operator==(const NamespacedName& other) const
{
return safeStrEq(mNamespace, other.mNamespace) && safeStrEq(mName, other.mName);
}
};
struct NamedValue
{
String mName;
uint32_t mValue;
NamedValue(String nm = "", uint32_t val = 0) : mName(nm), mValue(val)
{
}
};
template <typename T>
struct BaseDataTypeToTypeMap
{
bool compile_error;
};
template <PvdBaseType::Enum>
struct BaseTypeToDataTypeMap
{
bool compile_error;
};
// Users can extend this mapping with new datatypes.
template <typename T>
struct PvdDataTypeToNamespacedNameMap
{
bool Name;
};
// This mapping tells you the what class id to use for the base datatypes
//
#define DECLARE_BASE_PVD_TYPE(type) \
template <> \
struct BaseDataTypeToTypeMap<type> \
{ \
enum Enum \
{ \
BaseTypeEnum = PvdBaseType::type \
}; \
}; \
template <> \
struct BaseDataTypeToTypeMap<const type&> \
{ \
enum Enum \
{ \
BaseTypeEnum = PvdBaseType::type \
}; \
}; \
template <> \
struct BaseTypeToDataTypeMap<PvdBaseType::type> \
{ \
typedef type TDataType; \
}; \
template <> \
struct PvdDataTypeToNamespacedNameMap<type> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<type>() : Name("physx3", #type) \
{ \
} \
}; \
template <> \
struct PvdDataTypeToNamespacedNameMap<const type&> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<const type&>() : Name("physx3", #type) \
{ \
} \
};
DECLARE_TYPES
#undef DECLARE_BASE_PVD_TYPE
template <typename TDataType>
inline int32_t getPvdTypeForType()
{
return static_cast<PvdBaseType::Enum>(BaseDataTypeToTypeMap<TDataType>::BaseTypeEnum);
}
template <typename TDataType>
inline NamespacedName getPvdNamespacedNameForType()
{
return PvdDataTypeToNamespacedNameMap<TDataType>().Name;
}
#define DEFINE_PVD_TYPE_NAME_MAP(type, ns, name) \
template <> \
struct PvdDataTypeToNamespacedNameMap<type> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<type>() : Name(ns, name) \
{ \
} \
};
#define DEFINE_PVD_TYPE_ALIAS(newType, oldType) \
template <> \
struct PvdDataTypeToNamespacedNameMap<newType> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<newType>() : Name(PvdDataTypeToNamespacedNameMap<oldType>().Name) \
{ \
} \
};
DEFINE_PVD_TYPE_ALIAS(const void*, void*)
struct ArrayData
{
uint8_t* mBegin;
uint8_t* mEnd;
uint8_t* mCapacity; //>= stop
ArrayData(uint8_t* beg = NULL, uint8_t* end = NULL, uint8_t* cap = NULL) : mBegin(beg), mEnd(end), mCapacity(cap)
{
}
uint8_t* begin()
{
return mBegin;
}
uint8_t* end()
{
return mEnd;
}
uint32_t byteCapacity()
{
return static_cast<uint32_t>(mCapacity - mBegin);
}
uint32_t byteSize() const
{
return static_cast<uint32_t>(mEnd - mBegin);
} // in bytes
uint32_t numberOfItems(uint32_t objectByteSize)
{
if(objectByteSize)
return byteSize() / objectByteSize;
return 0;
}
void forgetData()
{
mBegin = mEnd = mCapacity = 0;
}
};
template <typename T>
class DataRef
{
const T* mBegin;
const T* mEnd;
public:
DataRef(const T* b, uint32_t count) : mBegin(b), mEnd(b + count)
{
}
DataRef(const T* b = NULL, const T* e = NULL) : mBegin(b), mEnd(e)
{
}
DataRef(const DataRef& o) : mBegin(o.mBegin), mEnd(o.mEnd)
{
}
DataRef& operator=(const DataRef& o)
{
mBegin = o.mBegin;
mEnd = o.mEnd;
return *this;
}
uint32_t size() const
{
return static_cast<uint32_t>(mEnd - mBegin);
}
const T* begin() const
{
return mBegin;
}
const T* end() const
{
return mEnd;
}
const T& operator[](uint32_t idx) const
{
PX_ASSERT(idx < size());
return mBegin[idx];
}
const T& back() const
{
PX_ASSERT(mEnd > mBegin);
return *(mEnd - 1);
}
};
struct PropertyType
{
enum Enum
{
Unknown = 0,
Scalar,
Array
};
};
// argument to the create property message function
struct PropertyMessageArg
{
String mPropertyName;
NamespacedName mDatatypeName;
// where in the message this property starts.
uint32_t mMessageOffset;
// size of this entry object
uint32_t mByteSize;
PropertyMessageArg(String propName, NamespacedName dtype, uint32_t msgOffset, uint32_t byteSize)
: mPropertyName(propName), mDatatypeName(dtype), mMessageOffset(msgOffset), mByteSize(byteSize)
{
}
PropertyMessageArg() : mPropertyName(""), mMessageOffset(0), mByteSize(0)
{
}
};
class PvdUserRenderer;
DEFINE_PVD_TYPE_NAME_MAP(PvdUserRenderer, "_debugger_", "PvdUserRenderer")
#if !PX_DOXYGEN
}
}
#endif
/** @} */
#endif // PXPVDSDK_PXPVDOBJECTMODELBASETYPES_H

View File

@ -0,0 +1,140 @@
//
// 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-2021 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 PXPVDSDK_PXPVDRENDERBUFFER_H
#define PXPVDSDK_PXPVDRENDERBUFFER_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxVec3.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
/**
\brief Default color values used for debug rendering.
*/
struct PvdDebugColor
{
enum Enum
{
eARGB_BLACK = 0xff000000,
eARGB_RED = 0xffff0000,
eARGB_GREEN = 0xff00ff00,
eARGB_BLUE = 0xff0000ff,
eARGB_YELLOW = 0xffffff00,
eARGB_MAGENTA = 0xffff00ff,
eARGB_CYAN = 0xff00ffff,
eARGB_WHITE = 0xffffffff,
eARGB_GREY = 0xff808080,
eARGB_DARKRED = 0x88880000,
eARGB_DARKGREEN = 0x88008800,
eARGB_DARKBLUE = 0x88000088
};
};
/**
\brief Used to store a single point and colour for debug rendering.
*/
struct PvdDebugPoint
{
PvdDebugPoint(const PxVec3& p, const uint32_t& c) : pos(p), color(c)
{
}
PxVec3 pos;
uint32_t color;
};
/**
\brief Used to store a single line and colour for debug rendering.
*/
struct PvdDebugLine
{
PvdDebugLine(const PxVec3& p0, const PxVec3& p1, const uint32_t& c) : pos0(p0), color0(c), pos1(p1), color1(c)
{
}
PxVec3 pos0;
uint32_t color0;
PxVec3 pos1;
uint32_t color1;
};
/**
\brief Used to store a single triangle and colour for debug rendering.
*/
struct PvdDebugTriangle
{
PvdDebugTriangle(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, const uint32_t& c)
: pos0(p0), color0(c), pos1(p1), color1(c), pos2(p2), color2(c)
{
}
PxVec3 pos0;
uint32_t color0;
PxVec3 pos1;
uint32_t color1;
PxVec3 pos2;
uint32_t color2;
};
/**
\brief Used to store a text for debug rendering. Doesn't own 'string' array.
*/
struct PvdDebugText
{
PvdDebugText() : string(0)
{
}
PvdDebugText(const PxVec3& p, const float& s, const uint32_t& c, const char* str)
: position(p), size(s), color(c), string(str)
{
}
PxVec3 position;
float size;
uint32_t color;
const char* string;
};
#if !PX_DOXYGEN
}
} // namespace physx
#endif
/** @} */
#endif // PXPVDSDK_PXPVDRENDERBUFFER_H

View File

@ -0,0 +1,107 @@
//
// 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-2021 NVIDIA Corporation. All rights reserved.
#ifndef PXPVDSDK_PXPVDUSERRENDERER_H
#define PXPVDSDK_PXPVDUSERRENDERER_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxVec3.h"
#include "foundation/PxTransform.h"
#include "pvd/PxPvd.h"
#include "PxPvdDataStream.h"
#include "PxPvdRenderBuffer.h"
#include "PsUserAllocated.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxPvd;
#if !PX_DOXYGEN
namespace pvdsdk
{
#endif
class RendererEventClient;
class PvdUserRenderer : public shdfnd::UserAllocated
{
protected:
virtual ~PvdUserRenderer()
{
}
public:
virtual void release() = 0;
virtual void setClient(RendererEventClient* client) = 0;
// Instance to associate the further rendering with.
virtual void setInstanceId(const void* instanceId) = 0;
// Draw these points associated with this instance
virtual void drawPoints(const PvdDebugPoint* points, uint32_t count) = 0;
// Draw these lines associated with this instance
virtual void drawLines(const PvdDebugLine* lines, uint32_t count) = 0;
// Draw these triangles associated with this instance
virtual void drawTriangles(const PvdDebugTriangle* triangles, uint32_t count) = 0;
// Draw this text associated with this instance
virtual void drawText(const PvdDebugText& text) = 0;
// Draw SDK debug render
virtual void drawRenderbuffer(const PvdDebugPoint* pointData, uint32_t pointCount, const PvdDebugLine* lineData,
uint32_t lineCount, const PvdDebugTriangle* triangleData, uint32_t triangleCount) = 0;
// Constraint visualization routines
virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, float value, bool active) = 0;
virtual void visualizeAngularLimit(const PxTransform& t0, float lower, float upper, bool active) = 0;
virtual void visualizeLimitCone(const PxTransform& t, float tanQSwingY, float tanQSwingZ, bool active) = 0;
virtual void visualizeDoubleCone(const PxTransform& t, float angle, bool active) = 0;
// Clear the immedate buffer.
virtual void flushRenderEvents() = 0;
static PvdUserRenderer* create(uint32_t bufferSize = 0x2000);
};
class RendererEventClient
{
public:
virtual ~RendererEventClient(){}
virtual void handleBufferFlush(const uint8_t* inData, uint32_t inLength) = 0;
};
#if !PX_DOXYGEN
}
}
#endif
/** @} */
#endif // PXPVDSDK_PXPVDUSERRENDERER_H