Move the shadow to the body's center (in the parent's coordinates) with its +z axis away from the light, and reshape the cones if the radii, the distance or the length set changed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(ShadowCones), | intent(inout) | :: | self |
subroutine place(self) type(ShadowCones), intent(inout) :: self real(wp) :: to_parent(4,4), m(4,4), b(3), s(3), u(3), d, now(4) ! the body's and the light's centers in the parent's coordinates to_parent = rigid_inverse(matmul(self%world_matrix(), rigid_inverse(self%local_matrix()))) m = matmul(to_parent, self%body_%world_matrix()) b = m(1:3, 4) m = matmul(to_parent, self%light_%world_matrix()) s = m(1:3, 4) u = b - s d = norm2(u) self%distance_ = d call self%set_position(b) if (d > 0.0_wp) call self%set_attitude(quat_from_vectors([0.0_wp, 0.0_wp, 1.0_wp], u / d)) now = [self%body_radius(), self%light_radius(), d, self%length_] if (all(now == self%shaped)) return self%shaped = now call shape_regions(self, now(1), now(2), d) end subroutine place