• Content count

  • Joined

  • Last visited

Community Reputation

127 Neutral

About DerekEhrman

  • Rank
  1. I would change a few things about your collision detection routine. First, I would store a radius instead of a diameter (why do the division constantly when what you really want is the radius? Just do the division once and you have the value to work from!). Second, I would make the hole itself also have a radius member so you can remove what appear to be *magic numbers* (where is 17 from?). I know the radius is constant in this example, but it would be much cleaner and cooler to support any sized hole, right? Now, your core collision detection is algorithm is doing more work than it needs to be (hypot uses the very expensive square root function) and is not an accurate representation of the object (I am assuming this is why you used the value 17 instead of the actual diameter value in your test?) I think you can greatly simplify the algorithm to something more like: * calculate the distance from the center of the hole to the center of the circle * add to this value, the radius of the circle * if this value is greater than or equal to the radius of the hole, we have a collision
  2. error lnk1104

    Just to be sure ... have you double-checked that you do indeed have the required lib on your machine in an appropriate location?
  3. SSE vector normalization

    [quote name='Cornstalks' timestamp='1343401501' post='4963662'] Sounds to me like a perfect time to use [url=""]assert[/url], like was suggested... [/quote] Agreed, I had meant to reiterate that a debug-only assertion was a valid solution!
  4. SSE vector normalization

    There is actually a very valid reason to simply crash on a 0 vector in your normalization function and I promise it has nothing to do with "ignorance or laziness". The entire point of using SSE is that it is high performance code. Normalization of a 0 vector, as previously stated is technically an invalid operation. Adding vector validation (i.e. checking for a 0 vector) in your normalization code will introduce unnecessary run-time overhead (in the form of potential branch mis-predictions and LHS) to a performance-sensitive area of your code. As the operation in question is technically invalid, those concerned with performance will opt to have the function crash rather than introduce the overhead. If this code crashes, the real bug lies elsewhere (the attempt to normalize a 0 vector ... why is your vector 0? Why are you trying to normalize it if it is? These are the bugs you should be concerned with). If there is a case in your code where you *may* be normalizing a 0 vector (direction derived via velocity when player is standing still perhaps?), then you should validate the vector *before* the attempt to normalize. The reason for this is that these cases are likely few and far between, and introducing the overhead that I explained above to *every* instance of a call to normalize is unfairly penalizing everyone who calls the function, whether they have a chance to pass a 0 vector or not.