The Lambda Lab
/
projects
/
raymarcher.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b2d510f
)
Unions and differences now take arrays as arguments.
author
Tim Vaughan
<timv@ughan.xyz>
Thu, 23 Feb 2023 15:07:08 +0000
(16:07 +0100)
committer
Tim Vaughan
<timv@ughan.xyz>
Thu, 23 Feb 2023 15:07:08 +0000
(16:07 +0100)
Operations.lua
patch
|
blob
|
history
diff --git
a/Operations.lua
b/Operations.lua
index
617916d
..
db9b9a7
100644
(file)
--- a/
Operations.lua
+++ b/
Operations.lua
@@
-1,25
+1,32
@@
-- Package of geometric operations on SDF objects
-- Package of geometric operations on SDF objects
-local function union(s
1, s2
)
+local function union(s
dfs
)
return function (location)
return function (location)
- local p
1 = s1
(location)
- local p
2 = s2(location)
+ local p
= sdfs[1]
(location)
+ local p
p = nil
- if p1.dist < p2.dist then
- return {dist = p1.dist, texture = p1.texture}
- else
- return {dist = p2.dist, texture = p2.texture}
+ for i=2,#sdfs do
+ pp = sdfs[i](location)
+ if pp.dist < p.dist then
+ p = pp
+ end
end
end
+
+ return p
end
end
end
end
-local function diff(s
1, s2
)
+local function diff(s
dfs
)
return function (location)
return function (location)
- local p
1 = s1
(location)
- local p
2 = s2(location)
+ local p
= sdfs[1]
(location)
+ local p
p = nil
- return {dist = math.max(p1.dist, -p2.dist),
- texture = p1.texture}
+ for i=2,#sdfs do
+ pp = sdfs[i](location)
+ p.dist = math.max(p.dist, -pp.dist)
+ end
+
+ return p
end
end
end
end