From e9e08a1d12594eab0e341049fc252ff8578e9333 Mon Sep 17 00:00:00 2001 From: Daniel Stokes Date: Tue, 17 Dec 2013 14:42:47 -0800 Subject: 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 --- source/blender/blenloader/intern/readfile.c | 19 +++++++++++++++++++ source/blender/blenloader/intern/writefile.c | 2 ++ 2 files changed, 21 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ac34f81907a..f3244a63a8b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4492,6 +4492,16 @@ static void lib_link_object(FileData *fd, Main *main) ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1); ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2); } + + { + LodLevel *level; + for (level = ob->lodlevels.first; level; level = level->next) { + level->source = newlibadr(fd, ob->id.lib, level->source); + + if (!level->source && level == ob->lodlevels.first) + level->source = ob; + } + } } } @@ -5026,6 +5036,9 @@ static void direct_link_object(FileData *fd, Object *ob) if (ob->sculpt) { ob->sculpt = MEM_callocN(sizeof(SculptSession), "reload sculpt session"); } + + link_list(fd, &ob->lodlevels); + ob->currentlod = ob->lodlevels.first; } /* ************ READ SCENE ***************** */ @@ -8396,6 +8409,12 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, ob->rigidbody_constraint->ob2); } + if (ob->currentlod) { + LodLevel *level; + for (level = ob->lodlevels.first; level; level = level->next) { + expand_doit(fd, mainvar, level->source); + } + } } static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index be81f355e26..fd8c711fb1a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1537,6 +1537,8 @@ static void write_objects(WriteData *wd, ListBase *idbase) write_particlesystems(wd, &ob->particlesystem); write_modifiers(wd, &ob->modifiers); + + writelist(wd, DATA, "LodLevel", &ob->lodlevels); } ob= ob->id.next; } -- cgit v1.2.3