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:
authorCampbell Barton <ideasman42@gmail.com>2012-08-18 20:16:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-18 20:16:13 +0400
commit27b4b45543c0f7690a1978a60591a0b5c0f1adbb (patch)
tree14c54494059de30d8d4c8a24ec8400b8bcc83ff5 /source/blender/blenkernel/intern/group.c
parente982e9b04f13be046d194643ed28aaedd6181f3b (diff)
utility functions: BLI_findptr, BLI_rfindptr --- use for finding an item in a linked list by a pointer.
Diffstat (limited to 'source/blender/blenkernel/intern/group.c')
-rw-r--r--source/blender/blenkernel/intern/group.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 89341845615..500df1b7b75 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -161,11 +161,13 @@ static int add_to_group_internal(Group *group, Object *ob)
{
GroupObject *go;
- if (group == NULL || ob == NULL) return 0;
+ if (group == NULL || ob == NULL) {
+ return FALSE;
+ }
/* check if the object has been added already */
- for (go = group->gobject.first; go; go = go->next) {
- if (go->ob == ob) return 0;
+ if (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob))) {
+ return FALSE;
}
go = MEM_callocN(sizeof(GroupObject), "groupobject");
@@ -173,7 +175,7 @@ static int add_to_group_internal(Group *group, Object *ob)
go->ob = ob;
- return 1;
+ return TRUE;
}
int add_to_group(Group *group, Object *object, Scene *scene, Base *base)
@@ -239,15 +241,11 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base)
int object_in_group(Object *ob, Group *group)
{
- GroupObject *go;
-
- if (group == NULL || ob == NULL) return 0;
-
- for (go = group->gobject.first; go; go = go->next) {
- if (go->ob == ob)
- return 1;
+ if (group == NULL || ob == NULL) {
+ return FALSE;
}
- return 0;
+
+ return (BLI_findptr(&group->gobject, ob, offsetof(GroupObject, ob)) != NULL);
}
Group *find_group(Object *ob, Group *group)