diff options
author | Daniel Stokes <kupomail@gmail.com> | 2013-12-18 02:42:47 +0400 |
---|---|---|
committer | kupoman <kupomail@gmail.com> | 2013-12-18 05:03:27 +0400 |
commit | e9e08a1d12594eab0e341049fc252ff8578e9333 (patch) | |
tree | ac7c15959b03398babb68058f3824c2a4dbff5b7 /source/blender/editors/object/object_lod.c | |
parent | 173f7a3d30db8cba95656bf03dc842b9300c2436 (diff) |
Game Engine: Level of detail support and tools
Levels of detail can be added and modified in the object panel. The object
panel also contains new tools for generating levels of detail, setting up
levels of detail based on object names (useful for importing), and
clearing an object's level of detail settings. This is meant as a game
engine feature, though the level of details settings can be previewed in
the viewport.
Reviewed By: moguri, nexyon, brecht
Differential Revision: http://developer.blender.org/D109
Diffstat (limited to 'source/blender/editors/object/object_lod.c')
-rw-r--r-- | source/blender/editors/object/object_lod.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_lod.c b/source/blender/editors/object/object_lod.c new file mode 100644 index 00000000000..952451ee21d --- /dev/null +++ b/source/blender/editors/object/object_lod.c @@ -0,0 +1,102 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/object/object_lod.c + * \ingroup edobj + */ + + +#include "DNA_object_types.h" + +#include "BKE_context.h" +#include "BKE_main.h" +#include "BKE_object.h" + +#include "ED_screen.h" +#include "ED_object.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "object_intern.h" + +static int object_lod_add_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + BKE_object_lod_add(ob); + return OPERATOR_FINISHED; +} + +void OBJECT_OT_lod_add(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Add Level of Detail"; + ot->description = "Add a level of detail to this object"; + ot->idname = "OBJECT_OT_lod_add"; + + /* api callbacks */ + ot->exec = object_lod_add_exec; + ot->poll = ED_operator_objectmode; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int object_lod_remove_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + int index = RNA_int_get(op->ptr, "index"); + if(!BKE_object_lod_remove(ob, index)) + return OPERATOR_CANCELLED; + + WM_event_add_notifier(C, NC_OBJECT|ND_LOD, CTX_wm_view3d(C)); + return OPERATOR_FINISHED; +} + +void OBJECT_OT_lod_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Level of Detail"; + ot->description = "Remove a level of detail from this object"; + ot->idname = "OBJECT_OT_lod_remove"; + + /* api callbacks */ + ot->exec = object_lod_remove_exec; + ot->poll = ED_operator_objectmode; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + ot->prop = RNA_def_int(ot->srna, "index", 1, 1, INT_MAX, "Index", "", 1, INT_MAX); +}
\ No newline at end of file |