mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Fix for planes not at the origin.
This commit is contained in:
parent
e552134cf5
commit
e545cfe406
1 changed files with 2 additions and 2 deletions
|
@ -211,13 +211,13 @@ void MetavoxelEditor::render() {
|
|||
glLineWidth(4.0f);
|
||||
glm::vec3 eyePosition = rotation * Application::getInstance()->getViewFrustum()->getOffsetPosition();
|
||||
glm::vec3 mousePoint = glm::vec3(_mousePosition, position);
|
||||
glm::vec3 right = glm::cross(glm::vec3(0.0f, 0.0f, 1.0f), mousePoint - eyePosition);
|
||||
glm::vec3 right = glm::cross(glm::vec3(0.0f, 0.0f, 1.0f), eyePosition - mousePoint);
|
||||
glm::vec3 normal = glm::cross(right, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
float divisor = glm::dot(normal, rayDirection);
|
||||
if (fabs(divisor) > EPSILON) {
|
||||
float distance = (glm::dot(normal, mousePoint) - glm::dot(normal, rayOrigin)) / divisor;
|
||||
float projection = rayOrigin.z + distance * rayDirection.z;
|
||||
_height = spacing * roundf(projection / spacing);
|
||||
_height = spacing * roundf(projection / spacing) - position;
|
||||
}
|
||||
} else if (fabs(rayDirection.z) > EPSILON) {
|
||||
// find the intersection of the rotated mouse ray with the plane
|
||||
|
|
Loading…
Reference in a new issue