.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   Please help to make TraceHull function which can takes mins & maxs (http://forums.bots-united.com/showthread.php?t=7233)

Immortal_BLG 25-08-2009 17:40

Please help to make TraceHull function which can takes mins & maxs
 
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. :(

SamPlay 02-09-2009 22:03

Re: Please help to make TraceHull function which can takes mins & maxs
 
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

Immortal_BLG 03-09-2009 12:15

Re: Please help to make TraceHull function which can takes mins & maxs
 
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....


All times are GMT +2. The time now is 09:09.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.