Fix bug where entities won't shadow points inside their own collision radius
Partial fix for issue #94 (needs a bit more doing for rock hermits, where the docking tunnel extends so deep into the object the "nearer sun than object" test unshadows the camera)
This commit is contained in:
parent
44d12970af
commit
a1efd52f9a
@ -477,7 +477,18 @@ BOOL shadowAtPointOcclusionToValue(HPVector e1pos, GLfloat e1rad, Entity *e2, OO
|
||||
// double theta_sun = asin( cr_sun / sqrt(d2_sun)); // 1/2 angle subtended by sun
|
||||
// double theta_e2 = asin( cr_e2 / sqrt(d2_e2)); // 1/2 angle subtended by e2
|
||||
// find the difference between the angles subtended by occluder and sun
|
||||
float theta_diff = asin(cr_e2 / sqrt(d2_e2)) - asin(cr_sun / sqrt(d2_sun));
|
||||
float d2_e = sqrt(d2_e2);
|
||||
float theta_diff;
|
||||
if (d2_e < cr_e2)
|
||||
{
|
||||
// then we're "inside" the object. Calculate as if we were on
|
||||
// the edge of it to avoid taking asin(x>1)
|
||||
theta_diff = asin(1) - asin(cr_sun / sqrt(d2_sun));
|
||||
}
|
||||
else
|
||||
{
|
||||
theta_diff = asin(cr_e2 / d2_e) - asin(cr_sun / sqrt(d2_sun));
|
||||
}
|
||||
|
||||
HPVector p_sun = the_sun->position;
|
||||
HPVector p_e2 = e2->position;
|
||||
|
Loading…
x
Reference in New Issue
Block a user