static int global_physics_sweep_col_mesh (lua_State *L)
{
TRY_START
        int base_line = 7;
        check_args_min(L, base_line);

        std::string col_mesh_name = check_path(L, 1);
        DiskResource *col_mesh_ = disk_resource_get_or_make(col_mesh_name);
        CollisionMesh *col_mesh = dynamic_cast<CollisionMesh*>(col_mesh_);
        Quaternion q = check_quat(L, 2);
        Vector3 start = check_v3(L, 3);
        Vector3 ray = check_v3(L, 4);
        bool nearest_only = check_bool(L, 5);
        unsigned long flags = check_t<unsigned long>(L, 6);
        if (lua_type(L, 7) != LUA_TFUNCTION)
                my_lua_error(L, "Parameter 5 should be a function.");

        LuaSweepCallback lcb(nearest_only, flags);
        init_cast_blacklist(L, base_line, lcb);

        physics_sweep_col_mesh(start, q, start + ray, q, lcb, col_mesh);

        push_cfunction(L, my_lua_error_handler);
        int error_handler = lua_gettop(L);

        lcb.pushResults(L, 7, error_handler);
        return 0;
TRY_END
}
Exemple #2
0
static int Label_multiline(lua_State* L){
	int args = check_args_min(L, 1);
	__M_GET_USERDATA(Label, self, 1);

	if(args == 1){ //multiline()
		lua_pushboolean(L, self.multiline());
		return 1;
	} else { //multiline(bool) we set it
		self.multiline(lua_toboolean(L, 2));
		return 0;
	}
}
static int global_physics_cast_ray (lua_State *L)
{
TRY_START
        int base_line = 4;
        check_args_min(L, base_line);

        Vector3 start = check_v3(L, 1);
        Vector3 ray = check_v3(L, 2);
        bool nearest_only = check_bool(L, 3);
        unsigned long flags = check_t<unsigned long>(L, 4);

        LuaSweepCallback lcb(nearest_only, flags);
        init_cast_blacklist(L, base_line, lcb);

        physics_ray(start, start+ray, lcb);

        return lcb.pushResults(L);

TRY_END
}
static int global_physics_sweep_cylinder (lua_State *L)
{
TRY_START
        int base_line = 7;
        check_args_min(L, base_line);

        float radius = check_float(L, 1);
        float height = check_float(L, 2);
        Quaternion q = check_quat(L, 3);
        Vector3 start = check_v3(L, 4);
        Vector3 ray = check_v3(L, 5);
        bool nearest_only = check_bool(L, 6);
        unsigned long flags = check_t<unsigned long>(L, 7);

        LuaSweepCallback lcb(nearest_only, flags);
        init_cast_blacklist(L, base_line, lcb);

        physics_sweep_cylinder(start, q, start+ray, lcb, radius, height);

        return lcb.pushResults(L);

TRY_END
}