Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Fix regression in Volumetrics, fixing original problem in a different…
Browse files Browse the repository at this point in the history
… way

Reverte commit 8a85505 that caused different (and probably worse) problems with Volumetrics, while adding code to solve the original problem that now I understand was calculating attenuation for points outside the region bounding box.
I hope this fix solves the original problem without causing new ones!
  • Loading branch information
DavidBluecame committed Sep 25, 2016
1 parent 2bab411 commit c5d571e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/yafraycore/volume.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ float VolumeRegion::attenuation(const point3d_t p, light_t *l)
float y = (p.y - bBox.a.y) / bBox.longY() * attGridY - 0.5f;
float z = (p.z - bBox.a.z) / bBox.longZ() * attGridZ - 0.5f;

//Check that the point is within the bounding box, return 0 if outside the box
if(x < -0.5f || y < -0.5f || z < -0.5f) return 0.f;
else if(x > (attGridX - 0.5f) || y > (attGridY - 0.5f) || z > (attGridZ - 0.5f)) return 0.f;

// cell vertices in which p lies
int x0 = floor(x);
int y0 = floor(y);
int z0 = floor(z);
int x0 = max(0, floor(x));
int y0 = max(0, floor(y));
int z0 = max(0, floor(z));

int x1 = min(attGridX - 1, ceil(x));
int y1 = min(attGridY - 1, ceil(y));
Expand Down

0 comments on commit c5d571e

Please sign in to comment.