Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Official Post Your Enging Coding Tips Thread Goto page Previous 1, 2, 3, 4

| Inside3d Forums Forum Index -> Engine Programming

View previous topic :: View next topic
Author | Message
--- | ---
Tomaz Joined: 05 Nov 2004 Posts: 49 |

Posted: Sun Aug 16, 2009 6:13 pm Post subject: |

reckless wrote:
tbh im not sure this is the one from fitz #define CLAMP(min, x, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) //johnfitz looks a bit more clean ill have to try it out and see if theres any difference.

Yeah that one makes the assumption that min is always smaller than max, the one i have handles the case where min might be bigger than max.

Back to top |

reckless Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger |

Posted: Sun Aug 16, 2009 11:29 pm Post subject: |

hmm interresting the bound value seems to assume that if the min value is greater or equal than the max value then min = max #define bound(min, x, max) ((min) >= (max) ? (min) : (x) < (min) ? (min) : (x) > (max) ? (max) : (x)) //slight rewrite hopefully a bit more readable
if i pull first part of it where it checks if min >= max then the rest of the function is the same as fitz as to why i got no clue. safeguard maybe ?
if (min >= max)
{
min = max;
}
// macro splits here
if (x < min)
{
x = min;
}
else if (x > max)
{
X = max;
}
else
{
x = x;
}
return x;

Back to top |

mh Joined: 12 Jan 2008 Posts: 910 |

Posted: Mon Aug 17, 2009 10:11 am Post subject: |

I posted this one elsewhere:

Quote:
Precalculating sizes and allocating in bulk is always good too. For example, you can figure out in advance how many glpoly_t structs (and the sizes of their vertexes) you need for non warp-surfaces, so why not just allocate a single big buffer at the end of Mod_LoadFaces and write the polys into that instead of doing a separate allocation for each poly?

_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines

Back to top |

Team Xlink Joined: 25 Jun 2009 Posts: 320 |

Posted: Fri Aug 21, 2009 3:48 pm Post subject: |

Another one: Your code isn't just supposed to work. It is supposed to work good. Avoid hack-ish code if possible, try to make your code efficient. _________________

Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!

Back to top |

reckless Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger |

Posted: Fri Aug 21, 2009 10:15 pm Post subject: |

indeed its better checking twice or more to make sure it actually runs, i had plenty of stuff that ran on my pc just to find out it didnt on anyone else pc "required msvc runtime missing or something so hacky only my own mess could run it xP"
thats why feedback is crucial we dont have all the hardware in the world to test releases against.
constructive feedback is probably the best resource in the world

Back to top |

Team Xlink Joined: 25 Jun 2009 Posts: 320 |

Posted: Mon Jan 25, 2010 8:39 pm Post subject: |

If your working on your own engine make sure you remove the #ifdef IDGODS code. It is Id software's backdoor for servers. It lost its usability after the source code release because the majority of engines removed it and it was made public. _________________

Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Engine Programming | All times are GMT Goto page Previous 1, 2, 3, 4
Page 4 of 4

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group