MCPcopy Create free account
hub / github.com/defold/defold / RenderScript_Predicate

Function RenderScript_Predicate

engine/render/src/render/render_script.cpp:2683–2710  ·  view source on GitHub ↗

creates a new render predicate * * This function returns a new render predicate for objects with materials matching * the provided material tags. The provided tags are combined into a bit mask * for the predicate. If multiple tags are provided, the predicate matches materials * with all tags ANDed together. * * The current limit to the number of tags that can be

Source from the content-addressed store, hash-verified

2681 * ```
2682 */
2683 static int RenderScript_Predicate(lua_State* L)
2684 {
2685 int top = lua_gettop(L);
2686 (void) top;
2687
2688 RenderScriptInstance* i = RenderScriptInstance_Check(L);
2689 (void)i;
2690 luaL_checktype(L, 1, LUA_TTABLE);
2691
2692 HPredicate* p_predicate = (HPredicate*) lua_newuserdata(L, sizeof(HPredicate*));
2693 *p_predicate = NewPredicate();
2694
2695 luaL_getmetatable(L, RENDER_SCRIPT_PREDICATE);
2696 lua_setmetatable(L, -2);
2697
2698 lua_pushnil(L); /* first key */
2699 while (lua_next(L, 1) != 0)
2700 {
2701 dmhash_t tag = dmScript::CheckHashOrString(L, -1);
2702 if (RESULT_OK != AddPredicateTag(*p_predicate, tag))
2703 {
2704 dmLogWarning("Unable to add predicate tag. Max number of tags (%i) reached?", dmRender::Predicate::MAX_TAG_COUNT);
2705 }
2706 lua_pop(L, 1);
2707 }
2708 assert(top + 1 == lua_gettop(L));
2709 return 1;
2710 }
2711
2712 /*# enables a material
2713 * If another material was already enabled, it will be automatically disabled

Callers

nothing calls this directly

Calls 11

lua_gettopFunction · 0.85
luaL_checktypeFunction · 0.85
lua_newuserdataFunction · 0.85
NewPredicateFunction · 0.85
lua_setmetatableFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
CheckHashOrStringFunction · 0.85
AddPredicateTagFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected