Hello.
I’ve been trying to use custom FContactModifyCallback to “carve” holes in the world.
For a test, I wrote a simple callback which should force bodies to ignore all contacts:
class FTestContactModifyCallback : public FContactModifyCallback
{
public:
void onContactModify(PxContactModifyPair* const pairs, PxU32 count) override
{
for (PxU32 i = 0; i < count; i++)
{
pairs->contacts.ignore(i);
}
}
};
And a custom factory for FPhysScene_PhysX::ContactModifyCallbackFactory:
class FTestContactModifyCallbackFactory : public IContactModifyCallbackFactory
{
public:
FContactModifyCallback* Create(FPhysScene_PhysX* PhysScene)
{
return new FTestContactModifyCallback();
}
void Destroy(FContactModifyCallback* Callback)
{
delete Callback;
}
};
I assign this custom factory at StartupModule method of my game module:
...
TSharedPtr<FTestContactModifyCallbackFactory> CustomCMCFactory;
virtual void StartupModule() override
{
CustomCMCFactory = MakeShareable(new FTestContactModifyCallbackFactory());
FPhysScene_PhysX::ContactModifyCallbackFactory = CustomCMCFactory;
}
...
In the game, when I’m turning on contact modification for component’s body instance, body attempts to fall through the floor but gets immediatly bounced back or completly stuck in the floor until other body ‘pops’ it out. This, however, does work for spheres: they fall through floor and pass through walls without any problems.
Am I missing something for this to work properly or this can’t done this way?
Thanks in advance.