Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-12-06 13:55:30 +0300
committerTon Roosendaal <ton@blender.org>2005-12-06 13:55:30 +0300
commitd024452ebf97c0926b1601371d2ee802bd754f3c (patch)
treeb6afebbe0b0cb682062bed92acbf33fe33b09aae /source/blender/blenkernel/intern/group.c
parent863234481e751ae94dd77b18d65ea76df65ec4b1 (diff)
Orange branch: Revived hidden treasure, the Groups!
Previous experiment (in 2000) didn't satisfy, it had even some primitive NLA option in groups... so, cleaned up the old code (removed most) and integrated it back in a more useful way. Usage: - CTRL+G gives menu to add group, add to existing group, or remove from groups. - In Object buttons, a new (should become first) Panel was added, showing not only Object "ID button" and Parent, but also the Groups the Object Belongs to. These buttons also allow rename, assigning or removing. - To indicate Objects are grouped, they're drawn in a (not theme yet, so temporal?) green wire color. - Use ALT+SHIFT mouse-select to (de)select an entire group But, the real power of groups is in the following features: -> Particle Force field and Guide control In the "Particle Motion" Panel, you can indicate a Group name, this then limits force fields or guides to members of that Group. (Note that layers still work on top of that... not sure about that). -> Light Groups In the Material "Shaders" Panel, you can indicate a Group name to limit lighting for the Material to lamps in this group. The Lights in a Group do need to be 'visible' for the Scene to be rendered (as usual). -> Group Duplicator In the Object "Anim" Panel, you can set any Object (use Empty!) to duplicate an entire Group. It will make copies of all Objects in that Group. Also works for animated Objects, but it will copy the current positions or deforms. Control over 'local timing' (so we can do Massive anims!) will be added later. (Note; this commit won't render Group duplicators yet, a fix in bf-blender will enable that, next commit will sync) -> Library Appending In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed. By appending or linking the Group itself, and use the Group Duplicator, you now can animate and position linked Objects. The nice thing is that the local saved file itself will only store the Group name that was linked, so on a next file read, the Group Objects will be re-read as stored (changed) in the Library file. (Note; current implementation also "gives a base" to linked Group Objects, to show them as Objects in the current Scene. Need that now for testing purposes, but probably will be removed later). -> Outliner Outliner now shows Groups as optio too, nice to organize your data a bit too! In General, Groups have a very good potential... for example, it could become default for MetaBall Objects too (jiri, I can help you later on how this works). All current 'layer relationships' in Blender should be dropped in time, I guess...
Diffstat (limited to 'source/blender/blenkernel/intern/group.c')
-rw-r--r--source/blender/blenkernel/intern/group.c229
1 files changed, 17 insertions, 212 deletions
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 65c4ed42e03..7405f16d9c0 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -1,19 +1,12 @@
-/* group.c sept 2000
- * - cleaned up mar-01 nzc
- *
- *
- * ton roosendaal
+/*
* $Id$
*
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
+ * 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
@@ -31,7 +24,7 @@
*
* Contributor(s): none yet.
*
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
*/
#include <stdio.h>
@@ -57,22 +50,8 @@
#include <config.h>
#endif
-void free_object_key(ObjectKey *ok)
-{
- if(ok->ipo) ok->ipo->id.us--;
-
- MEM_freeN(ok);
-}
-
void free_group_object(GroupObject *go)
{
- ObjectKey *ok;
-
- while(go->okey.first) {
- ok= go->okey.first;
- BLI_remlink(&go->okey, ok);
- free_object_key(ok);
- }
MEM_freeN(go);
}
@@ -82,14 +61,11 @@ void free_group(Group *group)
/* don't free group itself */
GroupObject *go;
- BLI_freelistN(&group->gkey);
-
while(group->gobject.first) {
go= group->gobject.first;
BLI_remlink(&group->gobject, go);
free_group_object(go);
}
-
}
Group *add_group()
@@ -100,97 +76,16 @@ Group *add_group()
return group;
}
-/* assumes 'ok' is unitialized */
-void object_to_obkey(Object *ob, ObjectKey *ok)
-{
- ok->partype= ob->partype;
- ok->par1= ob->par1;
- ok->par2= ob->par2;
- ok->par3= ob->par3;
-
- ok->parent= ob->parent;
- ok->track= ob->track;
-
- ok->ipo= copy_ipo(ob->ipo);
-
- memcpy(ok->loc, ob->loc, 7*3*sizeof(float));
- memcpy(ok->quat, ob->quat, 2*4*sizeof(float));
- memcpy(ok->obmat, ob->obmat, 3*4*4*sizeof(float));
-
- ok->lay= ob->lay;
- ok->transflag= ob->transflag;
- ok->trackflag= ob->transflag;
- ok->upflag= ob->upflag;
- ok->sf= ob->sf;
- ok->ctime= ob->ctime;
-
-
-}
-
-void obkey_to_object(ObjectKey *ok, Object *ob)
-{
- ob->partype= ok->partype;
- ob->par1= ok->par1;
- ob->par2= ok->par2;
- ob->par3= ok->par3;
-
- ob->parent= ok->parent;
- ob->track= ok->track;
-
- /* pretty tricky, this makes ob->ipo blocks with users 'hanging around' */
- if(ob->ipo) {
- free_libblock_us(&G.main->ipo, ob->ipo);
- }
- ob->ipo= copy_ipo(ok->ipo);
-
- memcpy(ob->loc, ok->loc, 7*3*sizeof(float));
- memcpy(ob->quat, ok->quat, 2*4*sizeof(float));
- memcpy(ob->obmat, ok->obmat, 3*4*4*sizeof(float));
-
- ob->lay= ok->lay;
- ob->transflag= ok->transflag;
- ob->trackflag= ok->transflag;
- ob->upflag= ok->upflag;
- ob->sf= ok->sf;
- ob->ctime= ok->ctime;
-}
-
-/* current ob position */
-void add_object_key(GroupObject *go, GroupKey *gk)
-{
- ObjectKey *ok;
-
- /* check if there already is a key */
- ok= go->okey.first;
- while(ok) {
- if(ok->gkey == gk) break;
- ok= ok->next;
- }
-
- if(ok) {
- BLI_remlink(&go->okey, ok);
- free_object_key(ok);
- }
- ok= MEM_mallocN(sizeof(ObjectKey), "objectkey");
- ok->gkey= gk;
-
- object_to_obkey(go->ob, ok);
-
- BLI_addtail(&go->okey, ok);
-
-}
-
/* external */
void add_to_group(Group *group, Object *ob)
{
GroupObject *go;
- GroupKey *gk;
+
+ if(group==NULL || ob==NULL) return;
/* check if the object has been added already */
- go= group->gobject.first;
- while(go) {
+ for(go= group->gobject.first; go; go= go->next) {
if(go->ob==ob) return;
- go= go->next;
}
go= MEM_callocN(sizeof(GroupObject), "groupobject");
@@ -198,18 +93,13 @@ void add_to_group(Group *group, Object *ob)
go->ob= ob;
- /* keys? */
- gk= group->gkey.first;
- while(gk) {
- add_object_key(go, gk);
- gk= gk->next;
- }
}
void rem_from_group(Group *group, Object *ob)
{
GroupObject *go, *gon;
- ObjectKey *ok;
+
+ if(group==NULL || ob==NULL) return;
go= group->gobject.first;
while(go) {
@@ -218,116 +108,31 @@ void rem_from_group(Group *group, Object *ob)
BLI_remlink(&group->gobject, go);
free_group_object(go);
}
- else {
- ok= go->okey.first;
- while(ok) {
- if(ok->parent==ob) ok->parent= NULL;
- if(ok->track==ob) ok->track= NULL;
- ok= ok->next;
- }
- }
go= gon;
}
}
-void add_group_key(Group *group)
+int object_in_group(Object *ob, Group *group)
{
GroupObject *go;
- GroupKey *gk;
- int nr=10;
- extern char colname_array[][20]; /* material.c */
-
- gk= group->gkey.first;
- while(gk) {
- nr++;
- gk= gk->next;
- }
-
- gk= MEM_callocN(sizeof(GroupKey), "groupkey");
- BLI_addtail(&group->gkey, gk);
- strcpy(gk->name, colname_array[ nr % 120 ]);
-
- go= group->gobject.first;
- while(go) {
- add_object_key(go, gk);
- go= go->next;
- }
-
- group->active= gk;
-}
-
-void set_object_key(Object *ob, ObjectKey *ok)
-{
- obkey_to_object(ok, ob);
-}
-
-void set_group_key(Group *group)
-{
- /* sets active */
- GroupObject *go;
- ObjectKey *ok;
- if(group->active==NULL) return;
+ if(group==NULL || ob==NULL) return 0;
- go= group->gobject.first;
- while(go) {
- ok= go->okey.first;
- while(ok) {
- if(ok->gkey==group->active) {
- set_object_key(go->ob, ok);
- break;
- }
- ok= ok->next;
- }
- go= go->next;
+ for(go= group->gobject.first; go; go= go->next) {
+ if(go->ob==ob)
+ return 1;
}
-
+ return 0;
}
Group *find_group(Object *ob)
{
Group *group= G.main->group.first;
- GroupObject *go;
while(group) {
-
- go= group->gobject.first;
- while(go) {
- if(go->ob==ob) return group;
- go= go->next;
- }
+ if(object_in_group(ob, group))
+ return group;
group= group->id.next;
}
return NULL;
}
-
-void set_group_key_name(Group *group, char *name)
-{
- GroupKey *gk;
-
- if(group==NULL) return;
-
- gk= group->gkey.first;
- while(gk) {
- if(strcmp(name, gk->name)==0) break;
- gk= gk->next;
- }
-
- if(gk) {
- group->active= gk;
- set_group_key(group);
- }
-}
-
-void set_group_key_frame(Group *group, float frame)
-{
- GroupObject *go;
-
- if(group==NULL) return;
-
- go= group->gobject.first;
- while(go) {
- where_is_object_time(go->ob, frame);
- go= go->next;
- }
-}