Fix failing tests caused by mul->scale
This commit is contained in:
parent
69f30173b8
commit
d19a5addcb
@ -1,3 +1,4 @@
|
||||
--- Various useful constants
|
||||
-- @module constants
|
||||
|
||||
--- Constants
|
||||
|
@ -138,7 +138,7 @@ function intersect.ray_triangle(ray, triangle)
|
||||
-- return position of intersection
|
||||
if t >= DBL_EPSILON then
|
||||
local out = vec3()
|
||||
out:mul(ray.direction, t)
|
||||
out:scale(ray.direction, t)
|
||||
out:add(ray.position, out)
|
||||
|
||||
return out
|
||||
@ -177,7 +177,7 @@ function intersect.ray_sphere(ray, sphere)
|
||||
t = t < 0 and 0 or t
|
||||
|
||||
local out = vec3()
|
||||
out:mul(ray.direction, t)
|
||||
out:scale(ray.direction, t)
|
||||
out:add(out, ray.position)
|
||||
|
||||
-- Return collision point and distance from ray origin
|
||||
@ -216,7 +216,7 @@ function intersect.ray_aabb(ray, aabb)
|
||||
end
|
||||
|
||||
local out = vec3()
|
||||
out:mul(ray.direction, tmin)
|
||||
out:scale(ray.direction, tmin)
|
||||
out:add(out, ray.position)
|
||||
|
||||
-- Return collision point and distance from ray origin
|
||||
@ -245,7 +245,7 @@ function intersect.ray_plane(ray, plane)
|
||||
end
|
||||
|
||||
local out = vec3()
|
||||
out:mul(ray.direction, t)
|
||||
out:scale(ray.direction, t)
|
||||
out:add(out, ray.position)
|
||||
|
||||
-- Return collision point and distance from ray origin
|
||||
@ -288,11 +288,11 @@ function intersect.line_line(a, b, e)
|
||||
|
||||
-- return positions of intersection on each line
|
||||
local out1 = vec3()
|
||||
out1:mul(p21, mua)
|
||||
out1:scale(p21, mua)
|
||||
out1:add(out1, a[1])
|
||||
|
||||
local out2 = vec3()
|
||||
out2:mul(p43, mub)
|
||||
out2:scale(p43, mub)
|
||||
out2:add(out2, b[1])
|
||||
|
||||
local dist = out1:dist(out2)
|
||||
|
@ -23,7 +23,7 @@ OctreeNode.__index = OctreeNode
|
||||
-- @param initialWorldSize Size of the sides of the initial node, in metres. The octree will never shrink smaller than this
|
||||
-- @param initialWorldPos Position of the centre of the initial node
|
||||
-- @param minNodeSize Nodes will stop splitting if the new nodes would be smaller than this (metres)
|
||||
-- @param loosenessVal Clamped between 1 and 2. Values > 1 let nodes overlap
|
||||
-- @param looseness Clamped between 1 and 2. Values > 1 let nodes overlap
|
||||
local function new(initialWorldSize, initialWorldPos, minNodeSize, looseness)
|
||||
local tree = setmetatable({}, Octree)
|
||||
|
||||
@ -354,6 +354,7 @@ end
|
||||
-- @param ray Ray with a position and a direction
|
||||
-- @param func Function to execute on any objects within child nodes
|
||||
-- @param out Table to store results of func in
|
||||
-- @param depth (used internally)
|
||||
-- @return boolean True if an intersect is detected
|
||||
function OctreeNode:cast_ray(ray, func, out, depth)
|
||||
depth = depth or 1
|
||||
@ -597,6 +598,7 @@ end
|
||||
|
||||
--- Draws the bounds of all objects in the tree visually for debugging.
|
||||
-- @param cube Cube model to draw
|
||||
-- @param filter a function returning true or false to determine visibility.
|
||||
function OctreeNode:draw_objects(cube, filter)
|
||||
local tint = self.baseLength / 20
|
||||
love.graphics.setColor(0, (1 - tint) * 255, tint * 255, 63)
|
||||
|
@ -143,7 +143,7 @@ end
|
||||
function vec2.trim(out, a, len)
|
||||
return out
|
||||
:normalize(a)
|
||||
:mul(out, math.min(a:len(), len))
|
||||
:scale(out, math.min(a:len(), len))
|
||||
end
|
||||
|
||||
--- Get the cross product of two vectors.
|
||||
@ -267,7 +267,7 @@ end
|
||||
function vec2.lerp(out, a, b, s)
|
||||
return out
|
||||
:sub(b, a)
|
||||
:mul(out, s)
|
||||
:scale(out, s)
|
||||
:add(out, a)
|
||||
end
|
||||
|
||||
|
@ -64,16 +64,16 @@ describe("vec2:", function()
|
||||
it("multiplies a vector by a scale factor", function()
|
||||
local a = vec2(3, 5)
|
||||
local s = 2
|
||||
local c = vec2():mul(a, s)
|
||||
local c = vec2():scale(a, s)
|
||||
local d = a * s
|
||||
assert.is.equal(6, c.x)
|
||||
assert.is.equal(10, c.y)
|
||||
assert.is.equal(c, d)
|
||||
end)
|
||||
|
||||
it("divides a vector by a scale factor", function()
|
||||
it("divides a vector by another vector", function()
|
||||
local a = vec2(3, 5)
|
||||
local s = 2
|
||||
local s = vec2(2, 2)
|
||||
local c = vec2():div(a, s)
|
||||
local d = a / s
|
||||
assert.is.equal(1.5, c.x)
|
||||
|
@ -71,7 +71,7 @@ describe("vec3:", function()
|
||||
it("multiplies a vector by a scale factor", function()
|
||||
local a = vec3(3, 5, 7)
|
||||
local s = 2
|
||||
local c = vec3():mul(a, s)
|
||||
local c = vec3():scale(a, s)
|
||||
local d = a * s
|
||||
assert.is.equal(6, c.x)
|
||||
assert.is.equal(10, c.y)
|
||||
@ -79,9 +79,9 @@ describe("vec3:", function()
|
||||
assert.is.equal(c, d)
|
||||
end)
|
||||
|
||||
it("divides a vector by a scale factor", function()
|
||||
it("divides a vector by another vector", function()
|
||||
local a = vec3(3, 5, 7)
|
||||
local s = 2
|
||||
local s = vec3(2, 2, 2)
|
||||
local c = vec3():div(a, s)
|
||||
local d = a / s
|
||||
assert.is.equal(1.5, c.x)
|
||||
|
Loading…
x
Reference in New Issue
Block a user