Exception unhandled in 0xcdcdcdcd en PruebaOgre 1.7.exe: 0xC0000005: Access violation

Hello
I’m trying things to get familiar with the SDK 3.3. And I created an application using the graphics engine Ogre3d in which I created a box and a plane. but I happen two problems … The first and most serious is that when I run the application, the compiler (Microsoft Visual C + + 2010) gives me this error:

First exception on PruebaOgre 0xcdcdcdcd 1.7.exe: 0xC0000005: Access violation.
Unhandled exception in 0xcdcdcdcd in PruebaOgre 1.7.exe: 0xC0000005: Access violation

The IDE tells me that the problem occurs on the thread PxWorker00 in the location “physx::Ext::CpuWorkerThread::execute”

I’ve got the application to run for some time by changing the starting position of the plane or box. And according to the values set, runs a few seconds. But after a few seconds the error appears again.

The second problem is that the box does not have collision with the plane. I guess it’s because I get over something

I have tried several things and I’ve looked at the documentation but I can not fix them. As much code involved several different classes and leave the link to files.h and cpp and VC2010 solution. The relevant files for this case are PhysXManager.h / cpp (which is responsible for starting and ending PhysX) and GameEntity.h / cpp (responsible creating actors of PhysX and the creating of graphic entities)

[url]http://www.mediafire.com/download/a5hm0hqc1h36hjw/PruebaOgre_1.7.rar[/url]

Can someone help?

Hi

finally! I´ve remembered my password. The password lost function wont work in this forum.

So - I would answer many questions but I was not able to do it.
Lets see what you got - I saw your post on the Ogre forum about the positioning your meshs -
its seems you need to read the PhysX Guide again.

You are lucky - I´m also using Ogre as my renderer (Using 1.9 from January 8th - own build for VS 2013)
(My name in the forum is the same as here)

I think you should download PhysX 3.3.1 which fixes some bugs, (but your problem is a bad pointer - maybe you didnt initialize a pointer or took it to the stack instead on the heap - the code 0xcdcdcdcd says it - a pointer which should always set to null - after it, you could initialize it. [Or you took it on the stack]) but I didnt view the code yet.

I´m going to look into your code and post what it could be.

I hope its compileable - just to test the fix for it.

Wait for it :D

Hi again

I see that you just rar´ed your solution directory while VS was running.
Some hints before viewing the code:
Delete all unnecessary files - it just pumpes the rar up.
[object files, pdb files, sdf…]

Ok, I think it wont start because there are no ddls.
Please upload all necessary dlls from the bin dir and send the link.
Since its a runtime error, and you are working with another version of Ogre, it wont run.
[Of course…there are problems with the missing includes / libs etc …]

Ok ok. I look only into the code.

Hi again x2

First:

Change line 58:
PxAllocatorCallback *allocator = &mDefaultAllocatorCallback;
to
mAllocator = new PxDefaultAllocator();
And store the pointer in your class.
[With this line, you force the allocator to the heap]

Line 61:
In my project, I implemented a simple ErrorCallback which inherits from PxErrorCallback
like this:

#include “PxErrorCallback.h”

class CErrorCallback : public PxErrorCallback
{
public:
void reportError(PxErrorCode::Enum e, const char* message, const char* file, int line);
};

Now implement reportError with life! (Simple printf works…)

after doing it, I´m force the ErrorCallback to the heap, you should also doing it.
[And of course, dont forget to delete them!]

And here is another one:
Use a local variable for your PxTolerancesScale which you set as parameter to PhysicCreation

PxTolerancesScale scale;
scale.mass = 1000.f;
scale.speed = 10.f;
scale.length = 1.f;

change it to mPhysicsSDK = PxCreatePhysics(PX_PHYSICS_VERSION, *mFoundation, scale
,recordMemoryAllocations);

Line 82:
Add this line before calling PxCreateCooking(…) (you are going to use it nowhere…)

if(!PxInitExtensions(*mSDK))
printf(“PxInitExtensions failed!”);

Line 91:
change it to PxDefaultCpuDispatcherCreate(0);

Unless you know how to deal with race coditions and buffering in PhysX.

Line 108: Memory leak. Save the pointer or create the material direct for your shapes.

Line 125: Wrong update loop. Look into my profile and dig around it - look for simulation loop
[semi-fixed or for right simulation stepping or similar]
DO IT! Search it! If you didnt done this, you having a lot of problems
I almost wrote it 10 times XD its incredible important to know how it works correctly, without knowing it, you could get may bugs like tunneling etc.

Line 77:
Change it to: mTransform.q = PxQuat(PxIdentity);
Line 83:
Change it to:
actorRigidDynamic = mPhysicsSDK->createRigidDynamic(mTransform);
PxShape* mShape = actorRigidDynamic ->createShape(geometry, *mMaterial);

Now you have full controll over it :D

For your plane geometry you could also use it like this, using a big flat box as eg.

Maybe it was better to code it instead to write it down :D

Hello, sorry for my clumsy English but I get really bad.

Firstly, thank you very much for the help and explanations. I seek Ogre forum and I’ll send you a private message and add as friend.

I managed to solve the problem of memory violation. It was the variable

“PxSimulationFilterShader :: gDefaultFilterShader”

that I defined by mistake in the fuction finalizarPhysX() instead of in the constructor() or the function inicializarPhysX().

So I modified the code and the function inicializarPhysX() I have done this:

gDefaultFilterShader = physx :: PxDefaultSimulationFilterShader; sceneDesc.filterShader = gDefaultFilterShader;

Despite not being a pointer variable, generated the error.

On the other hand I felt were interesting changes you suggested but there are some things I do not understand, so I’ll send a private message through the forums to see if PhysX me some bearings.

Thank you very much for everything. regards

Hi,

you are welcome.
It was a little hard to read the spain methods, due to I´m not able to speak spain.
My native language isn´t english too - but everything I code is on english even when its a small private
test project.

This is one of the thread I mention you should have read:

I´ve much to for my colleage, so I´m not very often here or in the Ogre forum,
but when you send me a pm I´ll answer it as fast as I can :D