Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

L. Spiro

Member Since 29 Oct 2003
Offline Last Active Today, 03:20 AM

Posts I've Made

In Topic: AABB box intersection test

Today, 01:39 AM

You forgot to handle the near clipping plane, which should be:

ret[4] = WVPMatrix[3] + WVPMatrix[2];

It is always a mistake to simplify the near plane “just because it’s only a small difference”.


Are there any obvious bugs?

#1: Your formulation of the math is suspect.
The plane’s dot product is with the center of the AABB.

But assuming the math works, you definitely will always get a positive (true) result because:

#2: You are returning true if the AABB is in front of (or intersecting) any plane on the frustum, which will always be the case in a well formed frustum.

You should instead be checking for the opposite, and returning false if the AABB is fully behind any plane in the frustum.

You should return true only if the AABB is in front of or intersecting all planes.



Additionally, Irlan is correct in mentioning the use of enumerated values for the frustum.

Furthermore, a plane<->AABB test must return either. FRONT, INTERSECT, or BACK.

If you are concerned about performance (as you should be with a frustum test) you will store planes with a -W (negate them after you extract them from the matrix).  This simplifies many plane equations, such as the one you have posted, which requires you to repeatedly (perhaps 100 times per frame instead of 6?) negate the W.



L. Spiro

In Topic: What heap wil dynamic memory be created on

24 November 2014 - 05:00 AM

Am I correct in my understanding of dynamic memory here?

There is only 1 heap.
The reason some libraries can’t deallocate allocations made by other libraries is because each library puts meta-data before an allocation to tell it how much has been allocated and etc. The format of this data may vary from library-to-library, and since it is necessary to deallocate it will cause a problem if an incompatible library tries to deallocate memory allocated by another library.

Who is responsible for deallocating the memory: Caller or Callee ?

The caller. It is your responsibility to make sure that the function you call to deallocate is designed to pair with the function you called to allocate.

If you use new, use delete to free.
If you use malloc(), use free() to free.
If you use a custom allocator, use the same custom deallocator.

It is that simple.

L. Spiro

In Topic: Easier/Quicker ways to capture screenshots on iPhone6

23 November 2014 - 08:51 AM

If you are talking about capturing your own screenshots from inside the game there is nothing you can’t do. Just decide what to do to take the shot and code it.
If you are talking about the Xcode debug feature, hit the button in Xcode.
If you are talking about something else, I don’t know.

L. Spiro

In Topic: OMSetRenderTargets is very slow on my machine.

21 November 2014 - 10:00 AM

Sometimes it takes 33ms and sometimes 16ms. Looks like 30 and 60 fps.

Disable v-sync.

L. Spiro

In Topic: Orthographic Projection, width/height

20 November 2014 - 04:47 PM

You need to investigate how that renderer class works and how its shaders are written because it is very obvious that it defines things in terms of “quadrants” per X and Y.

NDC space ranges from -1 to 1 in both X and Y, which means 2 units wide and 2 units tall.

So if you pass 2-by-2 you get a 1-to-1 ratio.

If you pass 1-by-1 it stretches 1 unit over the 2-unit range and your image is twice as big.

If you pass 800 for X, your image is 400 times thinner.



This is abnormal behavior and you should find the root of it.



L. Spiro