[C++-sig] PhysX3.x Wrapping Problems
Nikolay Mladenov
nikolay.mladenov at gmail.com
Wed Jan 29 16:21:50 CET 2014
Recently I had such symptom - it went away when I turned "Whole Program
Optimization" off
On Tue, Jan 28, 2014 at 11:33 AM, Peter Armbrüster <arm at rfh-koeln.de> wrote:
> Dear Boost.python, C++ and Py++ Experts,
>
>
>
> this is my first post in your excellent Forum.
>
>
>
> I have chosen as the wrapper software the boost.python/Py++ Package to
> write a physx 3.x Wrapper, because I think it is the best.
>
> Many many thanks to David Abrahams and Roman Yakovenko for the great Tools.
>
>
>
> The wrapping of old versions physx 2.x had made no problems.
>
> And now I come across a very big problem at the 3.x Versions.
>
> All wrappings of classes works very well.
>
> The problem only exists in the PhysX free functions, which are responsible
> for the initialization of PhysX.
>
>
>
> I try to explain with a reduced Example.
>
> The initialization of PhysX starts with create of foundation :
>
>
>
> *0 static* PxFoundation *mFoundation = NULL;
>
> *1 static* PxDefaultErrorCallback gDefaultErrorCallback;
> *2 static* PxDefaultAllocator gDefaultAllocatorCallback;
> 3 mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION,
> gDefaultAllocatorCallback, gDefaultErrorCallback); 4
> *4 if*(!mFoundation)
>
> 5 fatalError("PxCreateFoundation failed!");
>
>
>
> The wrapped python program generate a runtime error at line 3:RuntimeError: Access violation - no RTTI data!
>
> Its impossible to get mFoundation.
>
>
>
>
>
>
>
> *Notes: *
>
> - physx comes as SDK: only Headers, libs and dlls.
>
> - PxFoundation is a Abstract class:
>
>
>
> *class* PX_FOUNDATION_API PxFoundation
> {
> *public*:
> *virtual* *void* release() = 0;
> *virtual* PxErrorCallback& getErrorCallback() *const* = 0;
> *virtual* *void* setErrorLevel(PxErrorCode::Enum mask =
> PxErrorCode::eMASK_ALL) = 0;
> *virtual* PxErrorCode::Enum getErrorLevel() *const* = 0;
> *virtual* PxBroadcastingAllocator& getAllocator() *const* = 0;
> *virtual* PxAllocatorCallback& getAllocatorCallback() *const* = 0;
> *virtual* *bool* getReportAllocationNames() *const* = 0;
> *virtual* *void* setReportAllocationNames(*bool* value) = 0;
>
> *virtual* ~PxFoundation() {}
> };
>
>
>
> - The wrapping of PxFoundation makes no problem.
>
>
>
>
>
> To make sure that I made no mistake with the initialization of PhysX, I
> tried a different solution.
>
> A small function InitPhysX create the foundation, and GetFoundation get
> this.
>
>
>
> C++ Code:
>
>
> *using* *namespace* physx;
>
> PxU32 PHYSICS_VERSION = PX_PHYSICS_VERSION;
> *static* PxFoundation *mFoundation = NULL;
> *static* PxDefaultErrorCallback gDefaultErrorCallback;
> *static* PxDefaultAllocator gDefaultAllocatorCallback;
>
>
> PxFoundation* GetFoundation(){
> *return* mFoundation;
> }
>
> *void* InitPhysX() {
> mFoundation = PxCreateFoundation(
> PX_PHYSICS_VERSION,
> gDefaultAllocatorCallback,
> gDefaultErrorCallback);
>
> *if*(!mFoundation)
> printf("ERROR: PxCreateFoundation failed!\n");
>
>
> *else* printf("PxCreateFoundation created!\n");
> }
>
>
>
> The wrapped python program:
>
>
>
> 1 import _physx324_d as PX
>
> 2 PX.InitPhysX()
>
> 3 foundation = PX.GetFoundation()
>
>
>
> I get on line 2 the message: "PxCreateFoundation created!"
> => OK!
>
>
>
> On Line 3 the same error RuntimeError: Access violation - no RTTI data!
>
>
>
> Now i check the wrappings of PxCreateFoundation in
> _physx324_d_free_functions.pypp.cpp
>
>
>
> void register_free_functions(){
>
> . . .
>
>
>
> { //::GetFoundation
>
> typedef ::physx::PxFoundation * ( *GetFoundation_function_type )(
> );
>
> bp::def(
> "GetFoundation"
> , GetFoundation_function_type( &::GetFoundation )
> , bp::return_value_policy< bp::reference_existing_object >() );
>
> }
>
>
>
> . . .
>
>
>
>
>
> I think: return_value_policy< bp::reference_existing_object > thats
> right!?
>
>
>
> Then a debug session with PTVS, start with a break point in InitPhysX
>
> and inspect the mFoundation after the successful generation.
>
> Its a vptr with 9 Entries => thats right, PxFoundation has 9 Methods.
>
> That's all what I can see, because I have no source code and no pdb
> (symbols).
>
>
>
> I place the next Breakpoint in
>
> PxFoundation* GetFoundation(){
> *return* mFoundation;
> }
>
>
>
> to search the Error location.
>
>
>
> Then followed a trace trip through the code, for me is a journey through
> an unreadable jungles of wrapper C + + code.
>
> Unfortunately, I am not an C++Expert.
>
> The Error is not to find for me.
>
>
>
>
>
> The same problem occurs with PxCreatePhysics.
>
>
>
> My work enviroment:
>
> · Windows 7 x64
>
> · Python 2.7
>
> · physxVersion 3.24 (i try: 3.01, 3.23, 3.3, same problem)
>
> · visualStudioVersion 11 (i try: VS 9 and VS 10, same problem)
>
> · PythonTools for Visual Studio (PTVS)
>
> · Boost 1.55 (i try: 1.45, same problem)
>
> · gccxml 0.9
>
> · pyplusplus 1.0 svn 1.5.1
>
> · pygccxml 1.0 svn 1.5.1
>
>
>
>
>
>
>
> What is my mistake?
>
> I would be very grateful if someone could an expert help.
>
> Thanks for your response.
>
>
>
> Peter Armold
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> https://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20140129/35d6f148/attachment-0001.html>
More information about the Cplusplus-sig
mailing list