PhysX collision event and add shape

Posted By: oliver2s

PhysX collision event and add shape - 02/05/14 10:06

I don't know if this is 3DGS related oder PhysX related:

If I set collision flags and event (http://www.conitec.net/beta/pXent_setcollisionflag.htm) the event is only triggered if the physX ent collides with its initialized body. If I add some more shapes with "pXent_addshape" the collision event is not triggered if the new added shapes collide with something.
Posted By: Tele

Re: PhysX collision event and add shape - 02/07/14 12:00

Correct, the Collison stops after a time or the collision event is not triggered.
I dont no why, its a Bug?
Posted By: oliver2s

Re: PhysX collision event and add shape - 02/07/14 12:09

The collisions with added shapes works as they should be here, only the event isn't triggered.
Posted By: jcl

Re: PhysX collision event and add shape - 02/07/14 12:09

Have you tried adding the shapes first, then setting the collision flags?
Posted By: oliver2s

Re: PhysX collision event and add shape - 02/07/14 12:21

Yes.
Posted By: Tele

Re: PhysX collision event and add shape - 02/08/14 17:43

Hallo
Ok the problem
you cant sett NULL of this function.

pXent_setcollisionflag(eBlob, NULL, NX_NOTIFY_ON_START_TOUCH);

you must realy set the second entitie zb. bump of your terrain.

you = ent_for_name ("terrain_001"); // get pointer to that entity
pXent_setcollisionflag(my,you,NX_NOTIFY_ON_END_TOUCH);
my.event = Plop;

Then its work fine. ;-)

Tele
Posted By: oliver2s

Re: PhysX collision event and add shape - 02/19/14 10:07

Originally Posted By: oliver2s
I don't know if this is 3DGS related oder PhysX related:

If I set collision flags and event (http://www.conitec.net/beta/pXent_setcollisionflag.htm) the event is only triggered if the physX ent collides with its initialized body. If I add some more shapes with "pXent_addshape" the collision event is not triggered if the new added shapes collide with something.


Here I made a small test script where you can clearly see the problem. In the first line I made a #define for testing purpose, which adds a physX shape via pXent_addshape (no collision triggered). If the #define is commented out, no additional shape will be added (collision is triggered).

The physX test object can be move with A and D keys.

Code:
#define ADDITIONAL_SHAPE

#include <acknex.h>
#include <ackphysX.h>

void collision_event()
{
	if (event_type == EVENT_FRICTION) 
	{
		var time_=0;
		while(time_<2)
		{
			draw_text("collision detected",5,5,vector(0,0,255));
			time_+=time_step/16;
			wait(1);
		}
	}
}

void main()
{
	level_load(NULL);
	
	physX_open();

	ENTITY* ent1=ent_create(CUBE_MDL,vector(100,0,0),NULL);
	pXent_settype(ent1,PH_RIGID,PH_BOX);
	pXent_setbodyflag(ent1,NX_BF_FROZEN_POS_X,1);
	pXent_setbodyflag(ent1,NX_BF_FROZEN_POS_Z,1);
	pXent_setbodyflag(ent1,NX_BF_FROZEN_ROT,1);
	#ifdef ADDITIONAL_SHAPE
		ENTITY* ent1_shape=ent_create(CUBE_MDL,vector(100,16,0),NULL);
		pXent_addshape(ent1,ent1_shape,PH_BOX);
	#endif
	
	ENTITY* ent2=ent_create(CUBE_MDL,vector(100,40,0),NULL);
	pXent_settype(ent2,PH_STATIC,PH_POLY);
	
	pXent_setcollisionflag(ent1,ent2,NX_NOTIFY_ON_START_TOUCH);
	ent1.event=collision_event;

	while(1)
	{
		pXent_addvelcentral (ent1,vector(0,(key_a-key_d)*time_step*4,0));
		
		#ifdef ADDITIONAL_SHAPE
			ent1_shape.y=ent1.y+16;
		#endif

		wait(1);	
	}
}

Posted By: jcl

Re: PhysX collision event and add shape - 02/19/14 10:27

I can confirm the problem. We'll implement a workaround in the next update.
© 2024 lite-C Forums