Forum

Engine traceline?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Engine traceline?

Postby Mexicouger » Sun Nov 14, 2010 5:28 am

What would an engine traceline look like?
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby Eluan » Sun Nov 14, 2010 6:56 am

It would look like SV_Move...
Eluan
 
Posts: 10
Joined: Sun Jun 15, 2008 9:03 am
Location: Florianópolis, Brazil

Postby gnounc » Sun Nov 14, 2010 7:09 am

____________________________
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby Mexicouger » Sun Nov 14, 2010 9:03 am

(-_-)___________________________________________(-_-)

I coulda swore I seen something in the engine concerning tracelines(Using them in the engine, rather than qc)
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby Baker » Sun Nov 14, 2010 12:08 pm

Explain further what you mean?

I reworked MH's chase-cam fix into a client-side visibility function.

If that is what you are looking for, I can post it here. But explain what you are trying to do? Are you talking server side (QuakeC) or client side?
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mankrip » Sun Nov 14, 2010 2:44 pm

MH's method is really the best one. Long story short, regular tracelines only works for server-side physics.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby Downsider » Sun Nov 14, 2010 5:03 pm

SV_Move
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Postby Ranger366 » Sun Nov 14, 2010 5:16 pm

Baker wrote:I reworked MH's chase-cam fix into a client-side visibility function.


viewtopic.php?t=2711

hurray
User avatar
Ranger366
 
Posts: 203
Joined: Thu Mar 18, 2010 5:51 pm

Postby Mexicouger » Mon Nov 15, 2010 2:37 am

I mean like using a traceline in the engine. I have a traceline that I use in player_pre_think, and I can't find any way to make it false. It really is heavy on the framerate(I lose around 3-4 fps)

So I thought If I just did it in The engine, I might save some memory strains. And the function is to make the crosshairs turn red. when the traceline hits something that takes damage, the crosshair turns red.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby r00k » Mon Nov 15, 2010 7:39 am

Code: Select all
void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
{
   trace_t   trace;
   qboolean result;

   Q_memset (&trace, 0, sizeof(trace));
   trace.fraction = 1;

   //result is true if end is empty...
   result = SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
   
   if (!result)//hit something
   {
      VectorCopy (trace.endpos, impact);   
   }
   else
      VectorCopy (end, impact);   
}


unless you mean what the quakeC traceline looks like in C

Code: Select all
/*
=================
PF_traceline

Used for use tracing and shot targeting
Traces are blocked by bbox and exact bsp entities, and also slide box entities
if the tryents flag is set.

traceline (vector1, vector2, tryents)
=================
*/
void PF_traceline (void)
{
   float   *v1, *v2;
   trace_t   trace;
   int      nomonsters;
   edict_t   *ent;

   v1 = G_VECTOR(OFS_PARM0);
   v2 = G_VECTOR(OFS_PARM1);
   nomonsters = G_FLOAT(OFS_PARM2);
   ent = G_EDICT(OFS_PARM3);

   trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters ? MOVE_NOMONSTERS : MOVE_NORMAL, ent);

   pr_global_struct->trace_allsolid = trace.allsolid;
   pr_global_struct->trace_startsolid = trace.startsolid;
   pr_global_struct->trace_fraction = trace.fraction;
   pr_global_struct->trace_inwater = trace.inwater;
   pr_global_struct->trace_inopen = trace.inopen;

   VectorCopy (trace.endpos, pr_global_struct->trace_endpos);
   VectorCopy (trace.plane.normal, pr_global_struct->trace_plane_normal);
   pr_global_struct->trace_plane_dist =  trace.plane.dist;   

   if (trace.ent)
      pr_global_struct->trace_ent = EDICT_TO_PROG(trace.ent);
   else
      pr_global_struct->trace_ent = EDICT_TO_PROG(sv.edicts);
}

r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby Spike » Mon Nov 15, 2010 5:27 pm

Mexicouger wrote:So I thought If I just did it in The engine, I might save some memory strains. And the function is to make the crosshairs turn red. when the traceline hits something that takes damage, the crosshair turns red.


Thing is though, traceline *is* in the engine. Its a builtin... Meaning its built in to the engine.

do a traceline, check trace_ent.takedamage. easy!
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Mexicouger » Mon Nov 15, 2010 11:09 pm

Spike wrote:
Mexicouger wrote:So I thought If I just did it in The engine, I might save some memory strains. And the function is to make the crosshairs turn red. when the traceline hits something that takes damage, the crosshair turns red.


Thing is though, traceline *is* in the engine. Its a builtin... Meaning its built in to the engine.

do a traceline, check trace_ent.takedamage. easy!


Thing is, I have nowhere to put it but playerprethink, Which I hate clogging that up. My intention was to maybe move it to the engine for a speed increase
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby mankrip » Mon Nov 15, 2010 11:33 pm

Create a float crosshair_time, and use it to only run the traceline check at a fixed time interval, like 0.1 seconds.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby Sajt » Mon Nov 15, 2010 11:38 pm

The traceline is already done in engine code. All QC does is call the function. All the overhead isn't in the function call, it's what the function itself (which in the engine) is doing. Moving the traceline CALL to the engine won't solve anything.

In the other thread I posted an example of what mk suggested...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby frag.machine » Tue Nov 16, 2010 1:12 pm

Mexicouger wrote:
Spike wrote:
Mexicouger wrote:So I thought If I just did it in The engine, I might save some memory strains. And the function is to make the crosshairs turn red. when the traceline hits something that takes damage, the crosshair turns red.


Thing is though, traceline *is* in the engine. Its a builtin... Meaning its built in to the engine.

do a traceline, check trace_ent.takedamage. easy!


Thing is, I have nowhere to put it but playerprethink, Which I hate clogging that up. My intention was to maybe move it to the engine for a speed increase


*sigh*

Shoving bad code into the engine won't make things magically works. :roll:

traceline is already as optmized as it can be. If your QC code is slowing things down, maybe you should first consider that your code is the culprit. What exactly are you trying to do ?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest