Understanding projection overlay

Post your help queries and engine programming questions here

Understanding projection overlay

Postby robaldred » Tue Jul 01, 2014 12:08 pm

I'm wanting to work on the depth sorting.
Unfortunately i'm looking at the _projectionOverlay and _internalsOverlap methods in IgeEntity and scratching my head, :?

Is anyone able to explain what it's calculating and what it's comparing to determine if boxes are overlapping?

Here's the method im talking about
Code: Select all

   _projectionOverlap: function (otherObject) {
      var thisG3d = this._bounds3d,
         thisMin = {
            x: this._translate.x - thisG3d.x / 2,
            y: this._translate.y - thisG3d.y / 2,
            z: this._translate.z - thisG3d.z
         },
         thisMax = {
            x: this._translate.x + thisG3d.x / 2,
            y: this._translate.y + thisG3d.y / 2,
            z: this._translate.z + thisG3d.z
         },
         otherG3d = otherObject._bounds3d,
         otherMin = {
            x: otherObject._translate.x - otherG3d.x / 2,
            y: otherObject._translate.y - otherG3d.y / 2,
            z: otherObject._translate.z - otherG3d.z
         },
         otherMax = {
            x: otherObject._translate.x + otherG3d.x / 2,
            y: otherObject._translate.y + otherG3d.y / 2,
            z: otherObject._translate.z + otherG3d.z
         };

      return this._internalsOverlap(
         thisMin.x - thisMax.y,
         thisMax.x - thisMin.y,
         otherMin.x - otherMax.y,
         otherMax.x - otherMin.y
      ) && this._internalsOverlap(
         thisMin.x - thisMax.z,
         thisMax.x - thisMin.z,
         otherMin.x - otherMax.z,
         otherMax.x - otherMin.z
      ) && this._internalsOverlap(
         thisMin.z - thisMax.y,
         thisMax.z - thisMin.y,
         otherMin.z - otherMax.y,
         otherMax.z - otherMin.y
      );
   },

   _internalsOverlap: function (x0, x1, y0, y1) {
      var tempSwap;

      if (x0 > x1) {
         tempSwap = this._swapVars(x0, x1);
         x0 = tempSwap[0];
         x1 = tempSwap[1];
      }

      if (y0 > y1) {
         tempSwap = this._swapVars(y0, y1);
         y0 = tempSwap[0];
         y1 = tempSwap[1];
      }

      if (x0 > y0) {
         tempSwap = this._swapVars(x0, y0);
         x0 = tempSwap[0];
         y0 = tempSwap[1];

         tempSwap = this._swapVars(x1, y1);
         x1 = tempSwap[0];
         y1 = tempSwap[1];
      }

      return y0 < x1;
   },
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron