mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Lunatic: gv.getangle() vs. analogous Lua function test, add some anchors to doc.
Also, in listglobals.sh, check for file existence. git-svn-id: https://svn.eduke32.com/eduke32@4044 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
40a2e1da24
commit
e402467676
3 changed files with 57 additions and 0 deletions
|
@ -455,6 +455,7 @@ http://lua-users.org/lists/lua-l/2011-09/msg00534.html
|
||||||
* `sec.lotag=32768` results the member to contain `-32768`
|
* `sec.lotag=32768` results the member to contain `-32768`
|
||||||
* `sec.lotag=2^32` is undefined
|
* `sec.lotag=2^32` is undefined
|
||||||
|
|
||||||
|
[[bit_fields]]
|
||||||
Bit fields
|
Bit fields
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
|
|
||||||
|
@ -1717,6 +1718,7 @@ specific actor tile. For this reason, per-actor variables are implemented in a
|
||||||
value for every sprite index. They are also ``cleaned'' at unspecified
|
value for every sprite index. They are also ``cleaned'' at unspecified
|
||||||
intervals.
|
intervals.
|
||||||
|
|
||||||
|
[[con_actorvar]]
|
||||||
===== The type `con.actorvar(defaultval)` [_serializable_]
|
===== The type `con.actorvar(defaultval)` [_serializable_]
|
||||||
|
|
||||||
Creates and returns a new per-actor variable with default value `defaultval`
|
Creates and returns a new per-actor variable with default value `defaultval`
|
||||||
|
|
|
@ -20,6 +20,10 @@ fi
|
||||||
LUAC=luac
|
LUAC=luac
|
||||||
|
|
||||||
for f in "$@"; do
|
for f in "$@"; do
|
||||||
|
if [ ! -f "$f" ]; then
|
||||||
|
echo "$f: No such file"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
echo "[$f]"
|
echo "[$f]"
|
||||||
# Strip LuaJIT specific syntax first. Run luac and extract interesting lines.
|
# Strip LuaJIT specific syntax first. Run luac and extract interesting lines.
|
||||||
sed -r -e "s/[0-9]+U?LL/0/g" "$f" | $LUAC -p -l - | grep "${GS}ETTABUP.*; _ENV " |
|
sed -r -e "s/[0-9]+U?LL/0/g" "$f" | $LUAC -p -l - | grep "${GS}ETTABUP.*; _ENV " |
|
||||||
|
|
|
@ -740,3 +740,54 @@ local D = require("CON.DEFS")
|
||||||
checkfail('require("CON.DEFS").APLAYER=123', "modifying base module table forbidden")
|
checkfail('require("CON.DEFS").APLAYER=123', "modifying base module table forbidden")
|
||||||
-- Test with lunatic/test/rotfixed_actor.con.
|
-- Test with lunatic/test/rotfixed_actor.con.
|
||||||
print("DUKECAR="..tostring(D.DUKECAR))
|
print("DUKECAR="..tostring(D.DUKECAR))
|
||||||
|
|
||||||
|
do
|
||||||
|
print('---------- getangle test')
|
||||||
|
|
||||||
|
local function CreateGetAngFunc(roundfunc)
|
||||||
|
return function(x, y)
|
||||||
|
local ang = (1024/math.pi)*math.atan2(y, x) -- note the swapped args
|
||||||
|
return bit.band(roundfunc(ang), 2047)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local ourgetang = CreateGetAngFunc(math.ceil)
|
||||||
|
local ourgetangf = CreateGetAngFunc(math.floor)
|
||||||
|
|
||||||
|
local function printang(x, y)
|
||||||
|
printf('%4d,%4d: %13d, %16d, %16d', x, y,
|
||||||
|
gv.getangle(x, y), ourgetang(x, y), ourgetangf(x, y))
|
||||||
|
end
|
||||||
|
|
||||||
|
print " x, y: getangle(x, y) | math.atan2/ceil | math.atan2/floor"
|
||||||
|
printang(10, 100)
|
||||||
|
printang(10, -100)
|
||||||
|
printang(-10, -100)
|
||||||
|
printang(-10, 100)
|
||||||
|
|
||||||
|
printang(0, 0)
|
||||||
|
|
||||||
|
printang(1, 0)
|
||||||
|
printang(0, 1)
|
||||||
|
printang(-1, 0)
|
||||||
|
printang(0, -1)
|
||||||
|
|
||||||
|
local N=1e5
|
||||||
|
local r = 0
|
||||||
|
|
||||||
|
local t = gv.gethiticks()
|
||||||
|
for i=1,N do
|
||||||
|
r = r + gv.getangle(10, i)
|
||||||
|
end
|
||||||
|
local t1 = gv.gethiticks()-t
|
||||||
|
|
||||||
|
r = 0
|
||||||
|
t = gv.gethiticks()
|
||||||
|
for i=1,N do
|
||||||
|
r = r + ourgetang(10, i)
|
||||||
|
end
|
||||||
|
local t2 = gv.gethiticks()-t
|
||||||
|
|
||||||
|
printf('Time for %d runs: getangle: %.03f ms, math.atan2: %.03f ms', N, t1, t2)
|
||||||
|
print('----------')
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue