[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57759] branches/soc-2013-bge/source/ blender: Material level of detail is now working.
Daniel Stokes
kupomail at gmail.com
Wed Jun 26 08:16:39 CEST 2013
Revision: 57759
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57759
Author: kupoman
Date: 2013-06-26 06:16:39 +0000 (Wed, 26 Jun 2013)
Log Message:
-----------
Material level of detail is now working. Material levels of detail appear in all editing modes (sculpt, edit, etc).
Modified Paths:
--------------
branches/soc-2013-bge/source/blender/blenkernel/BKE_object.h
branches/soc-2013-bge/source/blender/blenkernel/intern/material.c
branches/soc-2013-bge/source/blender/blenkernel/intern/object.c
branches/soc-2013-bge/source/blender/editors/space_view3d/drawobject.c
Modified: branches/soc-2013-bge/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2013-bge/source/blender/blenkernel/BKE_object.h 2013-06-26 05:45:36 UTC (rev 57758)
+++ branches/soc-2013-bge/source/blender/blenkernel/BKE_object.h 2013-06-26 06:16:39 UTC (rev 57759)
@@ -87,7 +87,9 @@
void BKE_object_lod_add(struct Object *ob);
void BKE_object_lod_remove(struct Object *ob, int level);
void BKE_object_lod_update(struct Object *ob, float camera_position[3]);
+bool BKE_object_lod_check(struct Object *ob, struct Scene *scene);
struct Object *BKE_object_lod_meshob_get(struct Object *ob);
+struct Object *BKE_object_lod_matob_get(struct Object *ob);
struct Object *BKE_object_copy_ex(struct Main *bmain, struct Object *ob, int copy_caches);
struct Object *BKE_object_copy(struct Object *ob);
Modified: branches/soc-2013-bge/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/soc-2013-bge/source/blender/blenkernel/intern/material.c 2013-06-26 05:45:36 UTC (rev 57758)
+++ branches/soc-2013-bge/source/blender/blenkernel/intern/material.c 2013-06-26 06:16:39 UTC (rev 57759)
@@ -64,6 +64,7 @@
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
+#include "BKE_object.h"
#include "BKE_curve.h"
#include "GPU_material.h"
@@ -623,6 +624,9 @@
short *totcolp;
if (ob == NULL) return NULL;
+ if (BKE_object_lod_check(ob, NULL)) {
+ ob = BKE_object_lod_matob_get(ob);
+ }
/* if object cannot have material, (totcolp == NULL) */
totcolp = give_totcolp(ob);
Modified: branches/soc-2013-bge/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2013-bge/source/blender/blenkernel/intern/object.c 2013-06-26 05:45:36 UTC (rev 57758)
+++ branches/soc-2013-bge/source/blender/blenkernel/intern/object.c 2013-06-26 06:16:39 UTC (rev 57759)
@@ -987,6 +987,12 @@
return current;
}
+bool BKE_object_lod_check(struct Object *ob, struct Scene *scene)
+{
+ bool active = (scene) ? ob == OBACT : 0;
+ return (ob->mode == OB_MODE_OBJECT || !active);
+}
+
void BKE_object_lod_update(struct Object *ob, float camera_position[3])
{
LodLevel* cur_level = ob->currentlod;
@@ -1009,6 +1015,17 @@
return current->source;
}
+struct Object *BKE_object_lod_matob_get(struct Object *ob)
+{
+ LodLevel *current = ob->currentlod;
+
+ while( current->prev && (!current->use_mat || current->source->type != OB_MESH)) {
+ current = current->prev;
+ }
+
+ return current->source;
+}
+
SoftBody *copy_softbody(SoftBody *sb, int copy_caches)
{
SoftBody *sbn;
Modified: branches/soc-2013-bge/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2013-bge/source/blender/editors/space_view3d/drawobject.c 2013-06-26 05:45:36 UTC (rev 57758)
+++ branches/soc-2013-bge/source/blender/editors/space_view3d/drawobject.c 2013-06-26 06:16:39 UTC (rev 57759)
@@ -3231,9 +3231,8 @@
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
const bool is_obact = (ob == OBACT);
int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
- bool draw_lod = (ob->mode == OB_MODE_OBJECT || !is_obact);
- if (draw_lod) {
+ if (BKE_object_lod_check(ob, scene)) {
ob = BKE_object_lod_meshob_get(ob);
me = ob->data;
dm->release(dm);
More information about the Bf-blender-cvs
mailing list