Jump to content
Guest

Distance to Bounding Box

Recommended Posts

On 04/03/2018 at 11:26 AM, Tankbuster said:

I updated this slightly so it can accept other input;

 


pdth_fnc_pointIsInBox = {// original by pedeathtrian. returns true if unit is in objs bounding box
	params ["_unit","_obj"];
	private ["_pos"];
	switch (typename _unit) do
		{
			case "STRING": {_pos = getMarkerPos _unit};
			case "OBJECT": {_pos = getpos _unit};
			case "ARRAY": {_pos = _unit};
		};
	_uPos = _obj worldToModel _pos;
	_oBox = boundingBoxReal _obj;
	_inHelper = {
		params ["_pt0", "_pt1"];
		(_pt0 select 0 <= _pt1 select 0) && (_pt0 select 1 <= _pt1 select 1) && (_pt0 select 2 <= _pt1 select 2)
	};
	([_oBox select 0, _uPos] call _inHelper) && ([_uPos, _oBox select 1] call _inHelper)
};

 

 

Hello , i'm testing this script but it doesn't seem to work everytime 

for example here it returns false : 

ZhhcFCe.jpg

And here it returns true 

czP6ZPD.jpg

I just changed the chair's height between the screenshots 

 

I would like it to return true as soon as one box collides with the other 

edit : you'll understand the problem with this video 

 

Share this post


Link to post
Share on other sites

I changed this line 

        case "OBJECT": {_pos = getpos _unit};

to this 

        case "OBJECT": {_pos = ASLToAGL (getPosASL _unit)};

And i have better results. 

It would be even better if i could use the geometry lod instead of bounding box though

Share this post


Link to post
Share on other sites

Are you trying to get this info in 3den editor (like the video) or in game?

 

Share this post


Link to post
Share on other sites

The video is actually ingame, i just draw the boundingbox and move the chair with a script (while in spectator mode) :)

Share this post


Link to post
Share on other sites

If you're expecting something while in game, you could test the event handler "epeContactStart". Something like:

 

yourPot addEventHandler ["EpeContactStart", {
  params ["_object1", "_object2", "_selection1", "_selection2", "_force"];
  hint str [_object1, _object2, _selection1, _selection2, _force];
  }];

 

Share this post


Link to post
Share on other sites

The physx eventhandlers only work with objects that support it (I don't know for sure chairs etc do) and even then, it's a nasty system to work with.

  • Like 1

Share this post


Link to post
Share on other sites
Just now, Tankbuster said:

The physx eventhandlers only work with objects that support it (I don't know for sure chairs etc do) and even then, it's a nasty system to work with.

I have tested that before posting. Not saying that works at 100% but it worth to be tested. A good approach is to see what happen when you're running the preview with too close objects. In this case, the flowerPot falls. So, there is an epe contact.

Share this post


Link to post
Share on other sites

Your way is way better than trying to compute bounding box collisions then. Madness lies that way, surely?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×