mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-06 14:20:18 +00:00
RenderObject::updateCull is now float, some Lua additions
- add obj_getUpdateCull() - add obs parameter to getWallNormal(x, y, dist, obs) to control which obs to consider - add getPerformanceCounter(), getPerformanceFreq()
This commit is contained in:
parent
f0d580d873
commit
778a275ce2
3 changed files with 36 additions and 7 deletions
|
@ -1151,7 +1151,7 @@ void Entity::update(float dt)
|
||||||
Vector backupPos = position;
|
Vector backupPos = position;
|
||||||
Vector backupVel = vel;
|
Vector backupVel = vel;
|
||||||
|
|
||||||
bool doUpdate = (updateCull == -1 || (position - core->screenCenter).isLength2DIn(updateCull));
|
bool doUpdate = (updateCull < 0 || (position - core->screenCenter).isLength2DIn(updateCull));
|
||||||
if (doUpdate && !(pauseFreeze && dsq->game->isPaused()))
|
if (doUpdate && !(pauseFreeze && dsq->game->isPaused()))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1545,10 +1545,15 @@ luaFunc(obj_setUpdateCull)
|
||||||
{
|
{
|
||||||
RenderObject *r = robj(L);;
|
RenderObject *r = robj(L);;
|
||||||
if (r)
|
if (r)
|
||||||
r->updateCull = lua_tointeger(L, 2);
|
r->updateCull = lua_tonumber(L, 2);
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(obj_getUpdateCull)
|
||||||
|
{
|
||||||
|
RenderObject *r = robj(L);;
|
||||||
|
luaReturnNum(r ? r->updateCull : 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(obj_setPositionX)
|
luaFunc(obj_setPositionX)
|
||||||
{
|
{
|
||||||
|
@ -1836,6 +1841,7 @@ luaFunc(quad_getBorderAlpha)
|
||||||
RO_FUNC(getter, prefix, setCull ) \
|
RO_FUNC(getter, prefix, setCull ) \
|
||||||
RO_FUNC(getter, prefix, setCullRadius ) \
|
RO_FUNC(getter, prefix, setCullRadius ) \
|
||||||
RO_FUNC(getter, prefix, setUpdateCull ) \
|
RO_FUNC(getter, prefix, setUpdateCull ) \
|
||||||
|
RO_FUNC(getter, prefix, getUpdateCull ) \
|
||||||
RO_FUNC(getter, prefix, setRenderPass ) \
|
RO_FUNC(getter, prefix, setRenderPass ) \
|
||||||
RO_FUNC(getter, prefix, setOverrideRenderPass ) \
|
RO_FUNC(getter, prefix, setOverrideRenderPass ) \
|
||||||
RO_FUNC(getter, prefix, setPositionX ) \
|
RO_FUNC(getter, prefix, setPositionX ) \
|
||||||
|
@ -4850,12 +4856,13 @@ luaFunc(getWallNormal)
|
||||||
x = lua_tonumber(L, 1);
|
x = lua_tonumber(L, 1);
|
||||||
y = lua_tonumber(L, 2);
|
y = lua_tonumber(L, 2);
|
||||||
int range = lua_tointeger(L, 3);
|
int range = lua_tointeger(L, 3);
|
||||||
|
int obs = lua_tointeger(L, 4);
|
||||||
if (range == 0)
|
if (range == 0)
|
||||||
{
|
|
||||||
range = 5;
|
range = 5;
|
||||||
}
|
if (!obs)
|
||||||
|
obs = OT_BLOCKING;
|
||||||
|
|
||||||
Vector n = dsq->game->getWallNormal(Vector(x, y), range);
|
Vector n = dsq->game->getWallNormal(Vector(x, y), range, NULL, obs);
|
||||||
|
|
||||||
luaReturnVec2(n.x, n.y);
|
luaReturnVec2(n.x, n.y);
|
||||||
}
|
}
|
||||||
|
@ -7866,7 +7873,7 @@ luaFunc(entity_offsetUpdate)
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
int uc = e->updateCull;
|
float uc = e->updateCull;
|
||||||
e->updateCull = -1;
|
e->updateCull = -1;
|
||||||
float t = float(rand()%10000)/1000.0f;
|
float t = float(rand()%10000)/1000.0f;
|
||||||
e->update(t);
|
e->update(t);
|
||||||
|
@ -9150,6 +9157,24 @@ luaFunc(pe_isRunning)
|
||||||
luaReturnBool(pe && pe->isRunning());
|
luaReturnBool(pe && pe->isRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(getPerformanceCounter)
|
||||||
|
{
|
||||||
|
#ifdef BBGE_BUILD_SDL2
|
||||||
|
luaReturnNum((lua_Number)SDL_GetPerformanceCounter());
|
||||||
|
#else
|
||||||
|
luaReturnNum((lua_Number)SDL_GetTicks());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
luaFunc(getPerformanceFreq)
|
||||||
|
{
|
||||||
|
#ifdef BBGE_BUILD_SDL2
|
||||||
|
luaReturnNum((lua_Number)SDL_GetPerformanceFrequency());
|
||||||
|
#else
|
||||||
|
luaReturnNum((lua_Number)1000);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#define luaRegister(func) {#func, l_##func}
|
#define luaRegister(func) {#func, l_##func}
|
||||||
|
@ -10154,6 +10179,10 @@ static const struct {
|
||||||
luaRegister(isShader),
|
luaRegister(isShader),
|
||||||
luaRegister(isParticleEffect),
|
luaRegister(isParticleEffect),
|
||||||
|
|
||||||
|
luaRegister(getPerformanceCounter),
|
||||||
|
luaRegister(getPerformanceFreq),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef MK_FUNC
|
#undef MK_FUNC
|
||||||
#undef MK_ALIAS
|
#undef MK_ALIAS
|
||||||
|
|
|
@ -267,7 +267,7 @@ public:
|
||||||
bool shareColorWithChildren;
|
bool shareColorWithChildren;
|
||||||
|
|
||||||
bool cull;
|
bool cull;
|
||||||
int updateCull;
|
float updateCull;
|
||||||
int layer;
|
int layer;
|
||||||
|
|
||||||
InterpolatedVector *positionSnapTo;
|
InterpolatedVector *positionSnapTo;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue