From 9de24c82bab8fc6f1b8810979ac492787d32a964 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Apr 2014 11:48:04 +1000 Subject: View3D: disable LOD when game engine is disabled or ifdef'd --- source/blender/editors/object/object_lod.c | 11 +++++++++++ source/blender/editors/space_view3d/drawobject.c | 6 +++++- source/blender/editors/space_view3d/view3d_draw.c | 23 +++++++++++++++++++---- 3 files changed, 35 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_lod.c b/source/blender/editors/object/object_lod.c index fdce59b10ff..d02b69ba5cf 100644 --- a/source/blender/editors/object/object_lod.c +++ b/source/blender/editors/object/object_lod.c @@ -51,7 +51,13 @@ static int object_lod_add_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); + +#ifdef WITH_GAMEENGINE BKE_object_lod_add(ob); +#else + (void)ob; +#endif + return OPERATOR_FINISHED; } @@ -75,8 +81,13 @@ static int object_lod_remove_exec(bContext *C, wmOperator *op) Object *ob = ED_object_context(C); int index = RNA_int_get(op->ptr, "index"); +#ifdef WITH_GAMEENGINE if (!BKE_object_lod_remove(ob, index)) return OPERATOR_CANCELLED; +#else + (void)ob; + (void)index; +#endif WM_event_add_notifier(C, NC_OBJECT | ND_LOD, CTX_wm_view3d(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index e7f94485664..13e74ece692 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3406,7 +3406,11 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt, const unsigned char ob_wire_col[4], const short dflag) { - Object *ob = BKE_object_lod_meshob_get(base->object, scene); +#ifdef WITH_GAMEENGINE + Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, scene) : base->object; +#else + Object *ob = base->object; +#endif Mesh *me = ob->data; Material *ma = give_current_material(ob, 1); const bool hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene)); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 9b455748713..2552be9b83b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1992,8 +1992,12 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas copy_m4_m4(savedobmat, dob->ob->obmat); copy_m4_m4(dob->ob->obmat, dob->mat); savedlod = dob->ob->currentlod; - BKE_object_lod_update(dob->ob, rv3d->viewinv[3]); - + +#ifdef WITH_GAMEENGINE + if (rv3d->rflag & RV3D_IS_GAME_ENGINE) { + BKE_object_lod_update(dob->ob, rv3d->viewinv[3]); + } +#endif /* extra service: draw the duplicator in drawtype of parent, minimum taken * to allow e.g. boundbox box objects in groups for LOD */ @@ -3208,6 +3212,8 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) } } + +#ifdef WITH_GAMEENGINE static void update_lods(Scene *scene, float camera_pos[3]) { Scene *sce_iter; @@ -3219,6 +3225,8 @@ static void update_lods(Scene *scene, float camera_pos[3]) BKE_object_lod_update(ob, camera_pos); } } +#endif + /* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit) @@ -3242,8 +3250,15 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* setup view matrices */ view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); - /* Make sure LoDs are up to date */ - update_lods(scene, rv3d->viewinv[3]); + rv3d->rflag &= ~RV3D_IS_GAME_ENGINE; +#ifdef WITH_GAMEENGINE + if (STREQ(scene->r.engine, "BLENDER_GAME")) { + rv3d->rflag |= RV3D_IS_GAME_ENGINE; + + /* Make sure LoDs are up to date */ + update_lods(scene, rv3d->viewinv[3]); + } +#endif /* clear the background */ view3d_main_area_clear(scene, v3d, ar); -- cgit v1.2.3