local bump = {
_VERSION = 'bump v3.1.6',
_URL = 'https://github.com/kikito/bump.lua',
_DESCRIPTION = 'A collision detection library for Lua',
_LICENSE = [[
MIT LICENSE
Copyright (c) 2014 Enrique García Cota
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
}
------------------------------------------
-- Auxiliary functions
------------------------------------------
local DELTA = 1e-10 -- floating-point margin of error
local abs, floor, ceil, min, max = math.abs, math.floor, math.ceil, math.min, math.max
local function sign(x)
if x > 0 then return 1 end
if x == 0 then return 0 end
return -1
end
local function nearest(x, a, b)
if abs(a - x) < abs(b - x) then return a else return b end
end
local function assertType(desiredType, value, name)
if type(value) ~= desiredType then
error(name .. ' must be a ' .. desiredType .. ', but was ' .. tostring(value) .. '(a ' .. type(value) .. ')')
end
end
local function assertIsPositiveNumber(value, name)
if type(value) ~= 'number' or value <= 0 then
error(name .. ' must be a positive integer, but was ' .. tostring(value) .. '(' .. type(value) .. ')')
end
end
local function assertIsRect(x,y,w,h)
assertType('number', x, 'x')
assertType('number', y, 'y')
assertIsPositiveNumber(w, 'w')
assertIsPositiveNumber(h, 'h')
end
local defaultFilter = function()
return 'slide'
end
------------------------------------------
-- Rectangle functions
------------------------------------------
local function rect_getNearestCorner(x,y,w,h, px, py)
return nearest(px, x, x+w), nearest(py, y, y+h)
end
-- This is a generalized implementation of the liang-barsky algorithm, which also returns
-- the normals of the sides where the segment intersects.
-- Returns nil if the segment never touches the rect
-- Notice that normals are only guaranteed to be accurate when initially ti1, ti2 == -math.huge, math.huge
local function rect_getSegmentIntersectionIndices(x,y,w,h, x1,y1,x2,y2, ti1,ti2)
ti1, ti2 = ti1 or 0, ti2 or 1
local dx, dy = x2-x1, y2-y1
local nx, ny
local nx1, ny1, nx2, ny2 = 0,0,0,0
local p, q, r
for side = 1,4 do
if side == 1 then nx,ny,p,q = -1, 0, -dx, x1 - x -- left
elseif side == 2 then nx,ny,p,q = 1, 0, dx, x + w - x1 -- right
elseif side == 3 then nx,ny,p,q = 0, -1, -dy, y1 - y -- top
else nx,ny,p,q = 0, 1, dy, y + h - y1 -- bottom
end
if p == 0 then
if q <= 0 then return nil end
else
r = q / p
if p < 0 then
if r > ti2 then return nil
elseif r > ti1 then ti1,nx1,ny1 = r,nx,ny
end
else -- p > 0
if r < ti1 then return nil
elseif r < ti2 then ti2,nx2,ny2 = r,nx,ny
end
end
end
end
return ti1,ti2, nx1,ny1, nx2,ny2
end
-- Calculates the minkowsky difference between 2 rects, which is another rect
local function rect_getDiff(x1,y1,w1,h1, x2,y2,w2,h2)
return x2 - x1 - w1,
y2 - y1 - h1,
w1 + w2,
h1 + h2
end
local function rect_containsPoint(x,y,w,h, px,py)
return px - x > DELTA and py - y > DELTA and
x + w - px > DELTA and y + h - py > DELTA
end
local function rect_isIntersecting(x1,y1,w1,h1, x2,y2,w2,h2)
return x1 < x2+w2 and x2 < x1+w1 and
y1 < y2+h2 and y2 < y1+h1
end
local function rect_getSquareDistance(x1,y1,w1,h1, x2,y2,w2,h2)
local dx = x1 - x2 + (w1 - w2)/2
local dy = y1 - y2 + (h1 - h2)/2
return dx*dx + dy*dy
end
local function rect_detectCollision(x1,y1,w1,h1, x2,y2,w2,h2, goalX, goalY)
goalX = goalX or x1
goalY = goalY or y1
local dx, dy = goalX - x1, goalY - y1
local x,y,w,h = rect_getDiff(x1,y1,w1,h1, x2,y2,w2,h2)
local overlaps, ti, nx, ny
if rect_containsPoint(x,y,w,h, 0,0) then -- item was intersecting other
local px, py = rect_getNearestCorner(x,y,w,h, 0, 0)
local wi, hi = min(w1, abs(px)), min(h1, abs(py)) -- area of intersection
ti = -wi * hi -- ti is the negative area of intersection
overlaps = true
else
local ti1,ti2,nx1,ny1 = rect_getSegmentIntersectionIndices(x,y,w,h, 0,0,dx,dy, -math.huge, math.huge)
-- item tunnels into other
if ti1 and ti1 < 1 and (0 < ti1 + DELTA or 0 == ti1 and ti2 > 0) then
ti, nx, ny = ti1, nx1, ny1
overlaps = false
end
end
if not ti then return end
local tx, ty
if overlaps then
if dx == 0 and dy == 0 then
-- intersecting and not moving - use minimum displacement vector
local px, py = rect_getNearestCorner(x,y,w,h, 0,0)
if abs(px) < abs(py) then py = 0 else px = 0 end
nx, ny = sign(px), sign(py)
tx, ty = x1 + px, y1 + py
else
-- intersecting and moving - move in the opposite direction
local ti1, _
ti1,_,nx,ny = rect_getSegmentIntersectionIndices(x,y,w,h, 0,0,dx,dy, -math.huge, 1)
if not ti1 then return end
tx, ty = x1 + dx * ti1, y1 + dy * ti1
end
else -- tunnel
tx, ty = x1 + dx * ti, y1 + dy * ti
end
return {
overlaps = overlaps,
ti = ti,
move = {x = dx, y = dy},
normal = {x = nx, y = ny},
touch = {x = tx, y = ty},
itemRect = {x = x1, y = y1, w = w1, h = h1},
otherRect = {x = x2, y = y2, w = w2, h = h2}
}
end
------------------------------------------
-- Grid functions
------------------------------------------
local function grid_toWorld(cellSize, cx, cy)
return (cx - 1)*cellSize, (cy-1)*cellSize
end
local function grid_toCell(cellSize, x, y)
return floor(x / cellSize) + 1, floor(y / cellSize) + 1
end
-- grid_traverse* functions are based on "A Fast Voxel Traversal Algorithm for Ray Tracing",
-- by John Amanides and Andrew Woo - http://www.cse.yorku.ca/~amana/research/grid.pdf
-- It has been modified to include both cells when the ray "touches a grid corner",
-- and with a different exit condition
local function grid_traverse_initStep(cellSize, ct, t1, t2)
local v = t2 - t1
if v > 0 then
return 1, cellSize / v, ((ct + v) * cellSize - t1) / v
elseif v < 0 then
return -1, -cellSize / v, ((ct + v - 1) * cellSize - t1) / v
else
return 0, math.huge, math.huge
end
end
local function grid_traverse(cellSize, x1,y1,x2,y2, f)
local cx1,cy1 = grid_toCell(cellSize, x1,y1)
local cx2,cy2 = grid_toCell(cellSize, x2,y2)
local stepX, dx, tx = grid_traverse_initStep(cellSize, cx1, x1, x2)
local stepY, dy, ty = grid_traverse_initStep(cellSize, cy1, y1, y2)
local cx,cy = cx1,cy1
f(cx, cy)
-- The default implementation had an infinite loop problem when
-- approaching the last cell in some occassions. We finish iterating
-- when we are *next* to the last cell
while abs(cx - cx2) + abs(cy - cy2) > 1 do
if tx < ty then
tx, cx = tx + dx, cx + stepX
f(cx, cy)
else
-- Addition: include both cells when going through corners
if tx
没有合适的资源?快使用搜索试试~ 我知道了~
lua UI 框架
共6098个文件
info:1135个
meta:1106个
bin:1023个
4星 · 超过85%的资源 需积分: 41 54 下载量 182 浏览量
2018-08-24
18:26:21
上传
评论 3
收藏 37.25MB ZIP 举报
温馨提示
纯Lua版的UI框架,结合使用,高效开发,快速上手
资源推荐
资源详情
资源评论
收起资源包目录
lua UI 框架 (6098个子文件)
00000000000000001000000000000000 4KB
00000000000000002000000000000000 4KB
00000000000000003000000000000000 4KB
00000000000000004000000000000000 4KB
00000000000000004100000000000000 4KB
00000000000000005000000000000000 4KB
00000000000000005100000000000000 4KB
00000000000000006000000000000000 4KB
00000000000000006100000000000000 4KB
00000000000000007000000000000000 4KB
00000000000000007100000000000000 4KB
00000000000000008000000000000000 4KB
00000000000000008100000000000000 4KB
00000000000000009000000000000000 4KB
0000000000000000a000000000000000 4KB
0000000000000000a100000000000000 4KB
0000000000000000b000000000000000 4KB
0000000000000000c000000000000000 4KB
008c7d51ab86f3249b97e221450611ee 4KB
0096d1f2739184b4b9c8a60e2986fc1a 7KB
00b8c36a397bcff4882e718e798d225b 6KB
00ce0c1343160ce4d8fce9bac594bef8 9KB
00d8d5f1dace2d5418fd3ecad436351c 7KB
00e16a277119b0f49abe7ffd809ddaf1 6KB
01152017fdc52a745941f5aeadc290d3 6KB
01ba541dcfc83462093fd9106b9777dc 4KB
01c020d8abddc0145ac415a6b6af3cdd 22KB
02065a57099356942a622ee2eadb4ca0 6KB
0228ef9661ffc614ca5ef895bebb9cd5 5KB
0250a9d54bfb84b4598fd0d174b3acad 5KB
02515af090167f24fa788c9686fc9fde 4KB
02c8948288ba9ae4a80de421d45384d4 10KB
02e524619972bb34c9d3fc24e3288c70 18KB
0407efcde0777cd4fae613dbc4721216 12KB
043123a76c67293448c995af74563d5d 4KB
045c77d6d8d096d47b4f27c2e2e0dd3a 5KB
04723c573807ec245817261e30f9f0f9 5KB
057ce533da6a0d04cb99abd57e445dd9 13KB
059e5317bf3d04c0094c797779d2ac58 4KB
05bc92564dd5fc94e82c4e91596e06ff 4KB
065e4297f37ab6140a5406761ec7d5fc 5KB
07364fd5bd36fa348a7977eff7d7b4c6 24KB
0774aa285d4bdfe4da33f7f04f6f5362 4KB
07765a84ba9b1df42a314ac6ee08e203 4KB
0785ca63f9b676a48a4b8342c6383647 6KB
07a1b0657ca924143aad5d811b5480ab 5KB
07fe434c71d661243a552e6985d66977 38KB
07fe73fd1eadab34b877b9ddfbe8aa68 5KB
08038e70f176b2748896fba3ebc83dac 22KB
080c32b793bd5254cb5436bdce4cec91 5KB
088b72a28570684498d8999e6ffae21b 13KB
090eca16f9937cd42aa7cb9fcbce648e 23KB
09233a12826fc13469e58f49b795aa73 9KB
097c4cd80f8267749a06633dea866460 6KB
09a947e6fb84bb8468c24bfacbd5fb02 5KB
09fddd44a06beb44d9f234230a786b20 4KB
0a48d80df9a381c46bc3b2b8abc8c0f9 8KB
0aaa207488f45c848b8a6ca9fdd94082 12KB
0ad11579e782c8a48818adfe66506591 67KB
0afed6d729352054daaa301cd7ff9418 7KB
0b97d94048c923e4eb13c4bcc497a584 183KB
0bba24ae97924e4429fe71e7597e155c 4KB
0c074f622c1d5ed41aa0974f0afe7e0e 5KB
0c262c9b3fb8fe74090348cc49354f49 7KB
0cb39a6210bc5944697e7d26bb29146f 5KB
0d05ffecf33da574f9205356137a6d7b 5KB
0d1e8964dfdbc4d4484d13b66f425448 5KB
0d4df0ec89f56d5489cbec841ec03c23 4KB
0d4e91b4cb1e4604987749bb7d3ec038 6KB
0d8fcbfce2cf4494ba80c2176ba345e5 137KB
0d9bcd039b7764d4ba3d35723fa34bb3 7KB
0d9cd09e85bf5854e8157b07519ae923 22KB
0db34a30857cc874cb10ab12d33d23d8 5KB
0df127972338c5f4aa531a5f5b79d16a 9KB
0dfe366a86b0ada40b59d8b729612283 8KB
0e0fddf176973b64eb6143388d1f6ba3 5KB
0e21100043db9294c8cd130d348b5dd9 74KB
0e2c26f3c643ce343bf41bbed7c397a9 4KB
0e409d97475b14d4c94615106af1f8bb 21KB
0f06e34d4cf8a9648ae7db8ad06db41c 68KB
0f93f802fbf38ce4a9e38ec220ccefb7 5KB
0fbcc41511b2ebb48899f9f4cd024a57 4KB
lua.1 4KB
luac.1 4KB
luajit.1 2KB
luajit.1 2KB
108327651776ab840aa2439abf0f7785 11KB
10c5ae390ee841846987bf2425c55da1 4KB
10d84fff5b7daa74db22e310aea5e4e4 18KB
10ed046c9cc48834dbe26d375b908eb9 4KB
111555386d09ef34cb737d92d50f614c 5KB
112a894995059a840b7e9aef67478481 8KB
11909a5c724865642b2d1ef6ad290192 5KB
11a50805f73ae234b8241b31d9f1092d 9KB
11fda519eadd8574cac778b7b7ade9e5 10KB
12395b2b5a34970409e9dc992d6e695a 5KB
123d0766e3d171a4d9a90dd5dcb236ec 7KB
128687f550888b44fbfac761dc9eb11b 12KB
12d5c7b5f00212b4db0bf4ada177e661 4KB
1334e4699b6534645ba378bb1beb608c 5KB
共 6098 条
- 1
- 2
- 3
- 4
- 5
- 6
- 61
资源评论
- h1h2h31232023-08-03没有说明不会用呀
zhu77889900
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 同态加密python.zip
- 基于Python的PCA人脸识别算法的原理及实现代码详解+源码+详细代码解析+开发文档+数据(毕业设计&课程设计&项目开发)
- Decision tree20240105(1).ipynb
- zuoyezuoyezuoye
- zuoyezuoyezuoye
- 机械设计电机转子装配设备sw22非常好的设计图纸100%好用.zip
- 作业作业作业作业作业作业
- xdotool.c
- RLMD鲁棒性局部均值分解信号分量可视化(Matlab完整源码和数据)
- Screenshot_2024-04-26-17-17-26-36_9d26c6446fd7bb8e41d99b6262b17def.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功