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
| 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 |
nothing calls this directly
no test coverage detected