[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60124] branches/soc-2013-bge/source/ blender: Removing the need to have a LodLevel for every object by adding a few checks for special cases .
Daniel Stokes
kupomail at gmail.com
Sat Sep 14 02:00:18 CEST 2013
Revision: 60124
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60124
Author: kupoman
Date: 2013-09-14 00:00:17 +0000 (Sat, 14 Sep 2013)
Log Message:
-----------
Removing the need to have a LodLevel for every object by adding a few checks for special cases.
Modified Paths:
--------------
branches/soc-2013-bge/source/blender/blenkernel/intern/object.c
branches/soc-2013-bge/source/blender/blenloader/intern/readfile.c
Modified: branches/soc-2013-bge/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2013-bge/source/blender/blenkernel/intern/object.c 2013-09-13 23:58:47 UTC (rev 60123)
+++ branches/soc-2013-bge/source/blender/blenkernel/intern/object.c 2013-09-14 00:00:17 UTC (rev 60124)
@@ -962,14 +962,6 @@
/* Animation Visualization defaults */
animviz_settings_init(&ob->avs);
- /* LoD defaults */
- BKE_object_lod_add(ob);
- base = BLI_findlink(&ob->lodlevels, 0);
- base->distance = 0.0;
- base->use_mat = base->use_mesh = 1;
- base->source = ob;
- ob->currentlod = base;
-
return ob;
}
@@ -1000,8 +992,17 @@
{
LodLevel *lod = MEM_callocN(sizeof(LodLevel), "LoD Level");
LodLevel *last = ob->lodlevels.last;
+
+ /* If the lod list is empty, initialize it with the base lod level */
+ if (!last) {
+ LodLevel *base = MEM_callocN(sizeof(LodLevel), "Base LoD Level");
+ BLI_addtail(&ob->lodlevels, base);
+ base->use_mat = base->use_mesh = 1;
+ base->source = ob;
+ last = ob->currentlod = base;
+ }
- lod->distance = (last) ? last->distance + 25.0f : 25.0f;
+ lod->distance = last->distance + 25.0f;
lod->use_mesh = lod->use_mat = 1;
BLI_addtail(&ob->lodlevels, lod);
@@ -1023,6 +1024,14 @@
BLI_remlink(&ob->lodlevels, rem);
MEM_freeN(rem);
+ /* If there are no user defined lods, remove the base lod as well */
+ if (BLI_countlist(&ob->lodlevels) == 1) {
+ LodLevel *base = ob->lodlevels.first;
+ BLI_remlink(&ob->lodlevels, base);
+ MEM_freeN(base);
+ ob->currentlod = NULL;
+ }
+
return true;
}
@@ -1077,6 +1086,9 @@
{
LodLevel *current = ob->currentlod;
+ if (!current)
+ return ob;
+
while( current->prev && (!current->use_mesh || !current->source || current->source->type != OB_MESH)) {
current = current->prev;
}
@@ -1088,6 +1100,9 @@
{
LodLevel *current = ob->currentlod;
+ if (!current)
+ return ob;
+
while( current->prev && (!current->use_mat || !current->source || current->source->type != OB_MESH)) {
current = current->prev;
}
Modified: branches/soc-2013-bge/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-bge/source/blender/blenloader/intern/readfile.c 2013-09-13 23:58:47 UTC (rev 60123)
+++ branches/soc-2013-bge/source/blender/blenloader/intern/readfile.c 2013-09-14 00:00:17 UTC (rev 60124)
@@ -9666,23 +9666,6 @@
}
}
- /* Load defaults for the level of detail System */
- {
- Object *ob;
- LodLevel *base;
-
- for (ob = main->object.first; ob; ob = ob->id.next) {
- if (!ob->lodlevels.first) {
- BKE_object_lod_add(ob);
- base = BLI_findlink(&ob->lodlevels, 0);
- base->distance = 0.0;
- base->use_mat = base->use_mesh = 1;
- base->source = ob;
- ob->currentlod = base;
- }
- }
- }
-
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
More information about the Bf-blender-cvs
mailing list