Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Deleting PhysX Objects [Re: 3run] #406372
08/18/12 13:06
08/18/12 13:06
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
I make some changes so that it works really well.

Try this one:

Code:
///////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
///////////////////////////////////////////////////////////////////////////////
STRING* map01_str = "map1.wmb";
///////////////////////////////////////////////////////////////////////////////
function main(){
	// show all errors:
	warn_level = 6;
	// limit FPS:
	fps_max = 60;
	// set video parameters:
	video_set(800, 600, 16, 0);
	video_aspect = 1.333;
	// run physX:
	physX_open();
	// load the level:
	freeze_mode = 1;
	level_load(map01_str);
	wait(3);
	freeze_mode = 0;
}
///////////////////////////////////////////////////////////////////////////////
action hero_act(){
	VECTOR temp;
	// make me physical object:
	pXent_settype(my, PH_CHAR, PH_CAPSULE);
	// camera setup:
	camera.arc = 80;
	// main loop:
	while(1){
		// gui:
		draw_text("press space key to remove objects", 5, 5, COLOR_WHITE);
		// move entity:
		temp.x = 15 * (key_w - key_s) * time_step;
		temp.y = 15 * (key_a - key_d) * time_step;
		temp.z = 0;
		pXent_move(my, temp, nullvector);
		wait(1);
	}
}
///////////////////////////////////////////////////////////////////////////////
function ghost_ent(){
	// flags:
	set(my, PASSABLE | TRANSLUCENT);
	// alpha parameters: 
	my.alpha = 50;
}
///////////////////////////////////////////////////////////////////////////////
action char_act(){
	// create passable but visible model, to show you the bbox:
	ent_create("bbox.mdl", my.x, ghost_ent);
	// make me physical object:
	pXent_settype(my, PH_CHAR, PH_CAPSULE);
	// wait till space key is pressed:
	while(!key_space){ wait(1); }
	// unregister object from physX:	
	for(you = ent_next(NULL); you; you = ent_next(you))
	{
		if (you != ent_for_name("bbox_mdl_134"))
		{
			pXent_settype(you,0,0);
		}
	}
	// wait for a while:
	wait(-1);
	// remove object:
	ent_remove(my);
}
///////////////////////////////////////////////////////////////////////////////




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Deleting PhysX Objects [Re: rojart] #406373
08/18/12 16:15
08/18/12 16:15
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you mate, this is workaround that I use as well, but it should work the way I have made too


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Deleting PhysX Objects [Re: 3run] #406958
09/03/12 08:35
09/03/12 08:35
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hi, I just want to roll this up with a quick-fix:

in "ackphysx.h" there is an event "physX_ent_remove", which is called, when an entity is removed via ptr_remove. In that function, the DLL function pXent_settype is used to release the entity from the PhysX system. If you replace that call with

Code:
pXent_enable(ent, 0);



the entity is released from PhysX and the engine, all shapes are removed and the remaining PhysX system is stable.

So just replace the function in ackphysx.h with this one and it'll work:

Code:
function physX_ent_remove(ENTITY* ent)
{
    if (!NxPhysicsSDK)
        return;
        
    if (ent.body != NULL)
        pXent_enable(ent, 0);
        
    on_ent_remove_px(ent);
}



I am not 100% sure why this happens, but it works great for me: in the following pic you see a complex PhysX-setup in the engine and in the NVidia PhysX Visual Debugger:



When I remove all entities with ptr_remove and the above fix, the vehicle is removed correctly:



Without the fix, the entities are removed as well, but the shapes stay in place and all tree-trunks are flying into the sky.

Last edited by HeelX; 09/03/12 08:37.
Re: Deleting PhysX Objects [Re: HeelX] #407030
09/05/12 06:09
09/05/12 06:09
Joined: Dec 2003
Posts: 1,225
germany
gri Offline
Serious User
gri  Offline
Serious User

Joined: Dec 2003
Posts: 1,225
germany


hey thank you heelx for that



regards,
gri


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1