-
-
Notifications
You must be signed in to change notification settings - Fork 5
Queries
selimanac edited this page Dec 19, 2024
·
10 revisions
See: Category & Mask Bits
Query the possible overlaps using raw AABB.
Parameters
-
group_id
(uint8) - Group ID -
x
(float) - X position of AABB. -
y
(float) - Y position of AABB. -
width
(uint32) - Width of AABB. -
height
(uint32) - Height of AABB. -
mask_bits
(uint64)[optional] - Default is all -
get_manifold
(boolean)[optional] - Get collision manifold. Default is false
Returns
-
result
(table) - Table of possible overlapping AABB IDs or manifold. -
count
(uint32) - Count ofresult
table.
Example
local group_id = aabb.new_group()
-- Example mask
local collision_bits = {
PLAYER = 1,
ENEMY = 2,
ITEM = 4,
ALL = bit.bnot(0) -- -1 for all results
}
local mask_bits = bit.bor(collision_bits.ENEMY, collision_bits.ITEM) -- Example masks
local x = 0
local y = 0
local width = 50
local height = 50
local result, count = daabbcc.query_aabb(group_id, x, y, width, height, mask_bits)
if result then
for i = 1, count do
print(result[i])
end
end
Query the possible overlaps using AABB ID.
Parameters
-
group_id
(uint8) - Group ID -
aabb_id
(int32) - AABB ID. -
mask_bits
(uint64)[optional] - Default is all -
get_manifold
(boolean)[optional] - Get collision manifold. Default is false
Returns
-
result
(table) - Table of possible overlapping AABB IDs or manifold. -
count
(uint32) - Count ofresult
table.
Example
local group_id = aabb.new_group()
-- Example mask
local collision_bits = {
PLAYER = 1,
ENEMY = 2,
ITEM = 4,
ALL = bit.bnot(0) -- -1 for all results
}
local mask_bits = bit.bor(collision_bits.ENEMY, collision_bits.ITEM) -- Example masks
local width = 50
local height = 50
local go_url = msg.url("/go")
local aabb_id = aabb.insert_gameobject(group_id, go_url, width, height)
local result, count = daabbcc.query_id(group_id, aabb_id, mask_bits)
if result then
for i = 1, count do
print(result[i])
end
end
Query possible overlaps using a raw AABB. Returns a result table with AABB IDs and distances, ordered from closest to farthest.
Parameters
-
group_id
(uint8) - Group ID -
x
(float) - X position of AABB. -
y
(float) - Y position of AABB. -
width
(uint32) - Width of AABB. -
height
(uint32) - Height of AABB. -
mask_bits
(uint64)[optional] - Default is all -
get_manifold
(boolean)[optional] - Get collision manifold. Default is false
Returns
-
result
(table) - Table of possible overlapping AABBs or manifold. Theresult
table contains aabb_ids and distances or manifold. -
count
(uint32) - Count ofresult
table.
Example
local result, count = daabbcc.query_aabb_sort(group_id, x, y, width, height)
if result then
for i = 1, count do
pprint(result[i])
end
end
Query the possible overlaps using AABB ID. Returns a result table with IDs and distances, ordered from closest to farthest.
Parameters
-
group_id
(uint8) - Group ID -
aabb_id
(int32) - AABB ID. -
mask_bits
(uint64)[optional] - Default is all -
get_manifold
(boolean)[optional] - Get collision manifold. Default is false
Returns
-
result
(table) - Table of possible overlapping AABBs or manifold. Theresult
table contains aabb_ids and distances or manifold. -
count
(uint32) - Count ofresult
table.
Example
local result, count = daabbcc.query_id_sort(group_id, aabb_id)
if result then
for i = 1, count do
pprint(result[i])
end
end
If you find my Defold Extensions useful for your projects, please consider supporting it.
I'd love to hear about your projects! Please share your released projects that use my native extensions. It would be very motivating for me.