jerryzhou / aoi Goto Github PK
View Code? Open in Web Editor NEWarea of interest(AOI), Navigation-Mesh
area of interest(AOI), Navigation-Mesh
considering cross-platform, use c89 style please.
maybe you need this args for gcc or clang compiling
-Werror=declaration-after-statement -std=c89
in laoi.c
see line 4,5
#include </usr/local/include/lua.h>
#include </usr/local/include/lauxlib.h>
please use
#include <lua.h>
#include <lauxlib.h>
I guess I found some bugs
Something goes wrong while divide > 3.
see the code:
Is there anything wrong with myself?
local laoi = require "laoi"
for divide = 1, 10 do
local map = laoi.new_map({512, 512}, divide)
local unitA = laoi.new_unit(1, {56, 29})
map:unit_add(unitA)
local unitB = laoi.new_unit(2, {72, 31})
map:unit_add(unitB)
table.foreach(map:unit_search(unitA, 30), function(unitId, unit)
print(string.format("divide=%d,unitId=%d", divide, unitId))
end)
end
`
/* 获取可能存在数据的节点 */
for (i=0; i<4; ++i) {
tpos.x = offsets[2*i];
tpos.y = offsets[2*i+1];
/* 跟刚刚一样的节点 */
if (tnode && tpos.x >= tnode->code.pos.x
&& (tnode->code.pos.x + map->nodesizes[tnode->level].w > tpos.x)
&& tpos.y >= tnode->code.pos.y
&& (tnode->code.pos.y + map->nodesizes[tnode->level].h > tpos.y)) {
continue;
}
`
这里tnode一直是null,没有赋值,那if tnode的判断是多余了,还是有bug?
/* 搜集树上的所有单元 */
void imapcollectunit
....
unit = node->units;
for (;unit;unit=unit->next) {
这个 units链表中节点的next自己指向了自己,导致死循环。
(gdb) p unit
$8 = (iunit *) 0x7fffee67a618
(gdb) p unit->next
$9 = (struct iunit *) 0x7fffee67a618
(gdb) p unit->pre
$10 = (struct iunit *) 0x7fffee67a618
(gdb) p unit->node->units
$16 = (struct iunit *) 0x7fffee67a618
(gdb) p unit->next->next
$17 = (struct iunit *) 0x7fffee67a618
(gdb) p unit->next->next->next
$18 = (struct iunit *) 0x7fffee67a618
以上的问题是偶现的,由于逻辑有点复杂,暂时还没定位到问题,初步估计是 节点重复list_add_front(node->units, unit)导致的。
a nice lib!
but it can't be compatible with c89(and only on Mac?)
I made some changes, and add a lib for lua-wrap(so far so good) test.lua
It can be run on Mac/Linux(see Makefile) /Windows(msvc_build.bat)
see changes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.