Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Calexus

Member Since 03 Jan 2004
Offline Last Active Nov 11 2013 01:38 PM

Topics I've Started

std::vector as key in std::map?

06 July 2011 - 06:49 AM

I'm in the process of debugging a rather massive system and I keep getting back to a part of the code that makes heavy use of std::map<std::vector<long>, std::long<long> >, the code itself compiles perfectly well and for what I hear it has been working fine for years.

But still... is it really legal to use an std::vector as a key? I have never seen anyone use it before but I guess its legal as long as all the needed operators are provided.




Edit >> Sry forgot to say this is C++.



Optimized obb-frustum

25 June 2009 - 02:36 AM

Yesterday, after reading this and this, I decided to upgrade some old frustum culling code. Not that there is anything wrong with my old “classic” culling but the algorithm in that paper just seems a bit more effective and as they say less naïve. Anyway the problem is that it works fine for AABB, at least I haven't found any problems with it yet, but not for OOBB. According to the paper the only thing you have to do for it to work with OOBBs is projecting the frustum plane normals onto the OOBBs local coordinate axises and use this projected normal when selecting the p and n vertices. So it pretty much looks like this:
Construct the OOBB min/max vertices from the OOBB center and extents. 
Ignoring the orientation, otherwise the selection of n/p vertices wont work right? (of course I have tried both)

Foreach frustum plane
{
   Project plane normal. 
   projnorm= (x-axis DOT normal, y-axis DOT normal, z-axis DOT normal)

   Use the projected normal's xyz-sign to select the right n and p vertices.

   Test for intersection.
      Compute the p-vertex distance to the frustum plane, if negative return false.

      Else compute the n-vertex distance to the plane and if negative set a flag for intersecting.
}
return intersecting or true
In other words exactly as shown in the paper and the lighthouse page. My OBB consists of center, extents and orientation and my frustum consists of 6 planes (normals and d-value, pointing inwards). Both the OBB and the frustum are in worldspace. And the case when this fails is if I have a OBB rotated 45deg around th y-axis (up) and place it behind the frustum near-plane with one corner inside the frustum (in front of the near plane). Maybe I have been poking to long at this, going blind from all debugging data and drawing boxes... Anyway my question is. Have they left something out that is so obvious that it doesn't have to be mentioned and I simply don't realize it? And has anyone actually seen a working implementation of this, I can only find AABB examples?

[web] SQLite, selecting by time

07 May 2009 - 02:16 AM

I recently started to use sqlite and it have worked pretty well until now. Apparently sqlite stores timestamps (and everything else) as strings and I guess that's what is giving me problems. I have a table with a time column, using DATETIME('now') to get the time, and I want to select all rows made on a certain day or all rows older then a certain date. Something like: "SELECT * FROM table WHERE time > '$sometime'" Obviously this doesn't work very well, so my question is: does anyone know how to work with sqlite timestamps in a proper way?

Finding bit index

30 October 2008 - 03:54 AM

Anyone knows a nice way to find the index of a bit, that is without actually counting the bits? Or more precisely getting the index of the bit sett in an unsigned pow2.
unsigned x= 00000000 00010000b (16)

index= GetIndex(x) //should return 4 (starting at 0)

Multiple Binomial Distributions?

27 July 2008 - 04:40 AM

I am using Binomial Distribution to calculate the probability of a character inflicting an amount of damage on another character. It's a dice based system so the probability of a wound is based of a series of successful dice rolls. But thats not really important. What i calculate is the probability of scoring n wounds with k attacks all having probability p to wound. But I have come to where I want to know the probability of a character (or group of characters) with multiple attacks with different probability to wound to kill a target. Does that make any sense at all? Maybe an example can clear things up. Lets say I have a group of 3 characters. Character A have 3 attacks and each have a probability of 21% damaging creature X. Character B 7 attacks, probability 6%. Character C 2 attacks, probability 35%. Now what is the probability of this group with 12 attacks scoring 3 wounds on creature X? I can calculate the probability for each character scoring a number of wounds but how do I calculate the combined probability of the group?

PARTNERS