mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-02-08 20:46:19 +01:00
Return depth calculation as w
This commit is contained in:
parent
2e3d2b67b5
commit
5c4eedf17d
1 changed files with 1 additions and 3 deletions
|
@ -91,7 +91,6 @@ module PF
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Optionally return the result of w in some way (pointer / tuple?)
|
|
||||||
def self.apply(point : Vector3(Float64), matrix : Matrix(Float64, 16))
|
def self.apply(point : Vector3(Float64), matrix : Matrix(Float64, 16))
|
||||||
vec = Vector3.new(
|
vec = Vector3.new(
|
||||||
point.x * matrix[0, 0] + point.y * matrix[1, 0] + point.z * matrix[2, 0] + matrix[3, 0],
|
point.x * matrix[0, 0] + point.y * matrix[1, 0] + point.z * matrix[2, 0] + matrix[3, 0],
|
||||||
|
@ -100,7 +99,7 @@ module PF
|
||||||
)
|
)
|
||||||
w = point.x * matrix[0, 3] + point.y * matrix[1, 3] + point.z * matrix[2, 3] + matrix[3, 3]
|
w = point.x * matrix[0, 3] + point.y * matrix[1, 3] + point.z * matrix[2, 3] + matrix[3, 3]
|
||||||
vec /= w unless w == 0.0
|
vec /= w unless w == 0.0
|
||||||
vec
|
{vec, w}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -148,7 +147,6 @@ module PF
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Optionally return the result of w in some way (pointer / tuple?)
|
|
||||||
def apply(point : Vector3(Float64))
|
def apply(point : Vector3(Float64))
|
||||||
PF::Transform3d.apply(point, @matrix)
|
PF::Transform3d.apply(point, @matrix)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue