.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 1 SDK
Half-Life 1 SDK For developments focused around Half-Life (and its mods) Half-Life

Reply
 
Thread Tools
Please help to make TraceHull function which can takes mins & maxs
Old
  (#1)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Warning Please help to make TraceHull function which can takes mins & maxs - 25-08-2009

Please help to write a TraceHull function that takes mins and maxs arguments. I already have written it, but precisely I do not know correctly, or not.
Code:
inline void TraceHull (const Math::Vector3D &source, const Math::Vector3D &destination, const Math::Vector2D &mins, const Math::Vector2D &maxs, const HalfLifeEngine::SDK::Constants::TraceIgnore_t traceIgnore, HalfLifeEngine::SDK::Classes::Edict *const entityToSkip, HalfLifeEngine::SDK::Structures::TraceResult_t &traceResult)
{
	HalfLifeEngine::SDK::Structures::TraceResult_t tempTraceResult;
	float fraction = 1.0f;
	Math::Vector2D offset;
	bool isStartSolid = false, isAllSolid = false;

	for (offset.x = mins.x; offset.x < maxs.x; ++offset.x)
		for (offset.y = mins.y; offset.y < maxs.y; ++offset.y)
		{
			HalfLifeEngine::Globals::g_halfLifeEngine->TraceLine (source + offset, destination + offset, traceIgnore, entityToSkip, tempTraceResult);

			if (tempTraceResult.isStartSolid)
				isStartSolid = true;

			if (tempTraceResult.isAllSolid)
				isAllSolid = true;

			if (tempTraceResult.fraction < fraction)
			{
				traceResult = tempTraceResult;
				fraction = tempTraceResult.fraction;
			}
		}

	traceResult.isStartSolid = isStartSolid;
	traceResult.isAllSolid = isAllSolid;
}
Maybe there no needed to add offset for start of TraceLine() function???....

Please help.

I also wrote it for given 3D mins & maxs, but it's tooooooo SLOW!!! ]:{D
Code:
inline void TraceHull (const Math::Vector3D &source, const Math::Vector3D &destination, const Math::Vector3D &mins, const Math::Vector3D &maxs, const HalfLifeEngine::SDK::Constants::TraceIgnore_t traceIgnore, HalfLifeEngine::SDK::Classes::Edict *const entityToSkip, HalfLifeEngine::SDK::Structures::TraceResult_t &traceResult)
{
	HalfLifeEngine::SDK::Structures::TraceResult_t tempTraceResult;
	float fraction = 1.0f;
	Math::Vector3D offset;
	bool isStartSolid = false, isAllSolid = false;

	for (offset.x = mins.x; offset.x < maxs.x; ++offset.x)
		for (offset.y = mins.y; offset.y < maxs.y; ++offset.y)
			for (offset.z = mins.z; offset.z < maxs.z; ++offset.z)
			{
				HalfLifeEngine::Globals::g_halfLifeEngine->TraceLine (source + offset, destination + offset, traceIgnore, entityToSkip, tempTraceResult);

				if (tempTraceResult.isStartSolid)
					isStartSolid = true;

				if (tempTraceResult.isAllSolid)
					isAllSolid = true;

				if (tempTraceResult.fraction < fraction)
				{
					traceResult = tempTraceResult;
					fraction = tempTraceResult.fraction;
				}
			}

	traceResult.isStartSolid = isStartSolid;
	traceResult.isAllSolid = isAllSolid;
}
P.S as always sorry for bad english.

Last edited by Immortal_BLG; 26-08-2009 at 06:02..
  
Reply With Quote
Re: Please help to make TraceHull function which can takes mins & maxs
Old
  (#2)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: Please help to make TraceHull function which can takes mins & maxs - 02-09-2009

Hi,
I am not sure about what you are looking for, but I assume you want to code a function that provide a trace like the original SDK TraceHull function but for any axis aligned hull defined by the mins and maxs arguments.
Well, first of all you must be aware that SDK TraceHull uses a dedicated bsp tree associated with the hull number. As far as I remember, there are 3 such bsptrees, with one for a standing player and one for a crouching ( ducking ) one. these 3 bsptrees are pre-computed and stored in the .bsp file ( see ZHLT ie Zoner's Half Life Tool to see how). To put it simply, they are computed from the walls by thickening them to take into account the width of the hull; the same for the floor and the ceiling. The computation are quite involved and incompatible with a real-time use as you seem to want it.
Secondly, there exist an approximate computation ( used in quake code I think) which can be used in real-time, but I would think it is not good enough, and would not anyway give results equivalent to the former process.
Hope this helps!
samplay
  
Reply With Quote
Re: Please help to make TraceHull function which can takes mins & maxs
Old
  (#3)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Re: Please help to make TraceHull function which can takes mins & maxs - 03-09-2009

Thank you for answer! Your assumption is right. I need this function for the navigation mesh CheckCrouch() function taken from hl2 SDK, which called each frame in cycle on map learning. And for right working of this function, I need to know, how it realised in ZBot(еhat I do not know and likely I do not learn never) or made my TraceHull(). I'm using the second variant and also has looked into the BSPView trace.cpp source code, but TraceLine() released in this program does not hit entities, but that's needed for me. Besides I do not know how it is possible to convert on that is necessary for me.
Sorry for bad english....
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com