[Bf-blender-cvs] [02ae16fd6e8] hair_guides: BoundBox recalc for groom.
Lukas Tönne
noreply at git.blender.org
Tue Dec 19 13:56:08 CET 2017
Commit: 02ae16fd6e863639783e8810e6958f652c6287be
Author: Lukas Tönne
Date: Tue Dec 19 11:47:54 2017 +0000
Branches: hair_guides
https://developer.blender.org/rB02ae16fd6e863639783e8810e6958f652c6287be
BoundBox recalc for groom.
===================================================================
M source/blender/blenkernel/BKE_groom.h
M source/blender/blenkernel/intern/displist.c
M source/blender/blenkernel/intern/groom.c
M source/blender/blenkernel/intern/object.c
M source/blender/blenloader/intern/readfile.c
M source/blender/makesrna/intern/rna_groom.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_groom.h b/source/blender/blenkernel/BKE_groom.h
index e5088b4d8e3..202e0193855 100644
--- a/source/blender/blenkernel/BKE_groom.h
+++ b/source/blender/blenkernel/BKE_groom.h
@@ -45,4 +45,8 @@ struct Groom *BKE_groom_copy(struct Main *bmain, const struct Groom *groom);
void BKE_groom_make_local(struct Main *bmain, struct Groom *groom, const bool lib_local);
+
+bool BKE_groom_minmax(struct Groom *groom, float min[3], float max[3]);
+void BKE_groom_boundbox_calc(struct Groom *groom, float r_loc[3], float r_size[3]);
+
#endif /* __BKE_GROOM_H__ */
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index dbc26ab8ad3..36e2151989e 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -771,6 +771,7 @@ void BKE_displist_make_groom(const EvaluationContext *eval_ctx, Scene *scene, Ob
}
// TODO
+ UNUSED_VARS(eval_ctx, scene);
boundbox_displist_object(ob);
}
diff --git a/source/blender/blenkernel/intern/groom.c b/source/blender/blenkernel/intern/groom.c
index cd0a38dcbb7..fcc4f60cba7 100644
--- a/source/blender/blenkernel/intern/groom.c
+++ b/source/blender/blenkernel/intern/groom.c
@@ -37,12 +37,14 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
+#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_string_utils.h"
#include "BLT_translation.h"
#include "DNA_groom_types.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_animsys.h"
@@ -50,11 +52,14 @@
#include "BKE_groom.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_object.h"
void BKE_groom_init(Groom *groom)
{
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(groom, id));
+
+ groom->bb = BKE_boundbox_alloc_unit();
}
void *BKE_groom_add(Main *bmain, const char *name)
@@ -82,7 +87,11 @@ void BKE_groom_free(Groom *groom)
*/
void BKE_groom_copy_data(Main *UNUSED(bmain), Groom *groom_dst, const Groom *groom_src, const int UNUSED(flag))
{
- UNUSED_VARS(groom_dst, groom_src);
+ groom_dst->bb = MEM_dupallocN(groom_src->bb);
+
+ BLI_duplicatelist(&groom_dst->bundles, &groom_src->bundles);
+
+ groom_dst->edit_groom = NULL;
}
Groom *BKE_groom_copy(Main *bmain, const Groom *groom)
@@ -96,3 +105,45 @@ void BKE_groom_make_local(Main *bmain, Groom *groom, const bool lib_local)
{
BKE_id_make_local_generic(bmain, &groom->id, true, lib_local);
}
+
+
+bool BKE_groom_minmax(Groom *groom, float min[3], float max[3])
+{
+ // TODO
+ UNUSED_VARS(groom, min, max);
+ return true;
+}
+
+void BKE_groom_boundbox_calc(Groom *groom, float r_loc[3], float r_size[3])
+{
+ if (groom->bb == NULL)
+ {
+ groom->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
+ }
+
+ float mloc[3], msize[3];
+ if (!r_loc)
+ {
+ r_loc = mloc;
+ }
+ if (!r_size)
+ {
+ r_size = msize;
+ }
+
+ float min[3], max[3];
+ INIT_MINMAX(min, max);
+ if (!BKE_groom_minmax(groom, min, max)) {
+ min[0] = min[1] = min[2] = -1.0f;
+ max[0] = max[1] = max[2] = 1.0f;
+ }
+
+ mid_v3_v3v3(r_loc, min, max);
+
+ r_size[0] = (max[0] - min[0]) / 2.0f;
+ r_size[1] = (max[1] - min[1]) / 2.0f;
+ r_size[2] = (max[2] - min[2]) / 2.0f;
+
+ BKE_boundbox_init_from_minmax(groom->bb, min, max);
+ groom->bb->flag &= ~BOUNDBOX_DIRTY;
+}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index cabeb9cada5..2a961d02c34 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -42,6 +42,7 @@
#include "DNA_constraint_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_group_types.h"
+#include "DNA_groom_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
@@ -338,6 +339,13 @@ void BKE_object_free_derived_caches(Object *ob)
atomic_fetch_and_or_int32(&cu->bb->flag, BOUNDBOX_DIRTY);
}
}
+ else if (ELEM(ob->type, OB_GROOM)) {
+ Groom *groom = ob->data;
+
+ if (groom && groom->bb) {
+ atomic_fetch_and_or_int32(&groom->bb->flag, BOUNDBOX_DIRTY);
+ }
+ }
if (ob->bb) {
MEM_freeN(ob->bb);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index dab6962fced..0f1a8e989ef 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8390,13 +8390,13 @@ static void lib_link_grooms(FileData *fd, Main *bmain)
}
}
-static void direct_link_groom(FileData *fd, Groom *groom, const Main *main)
+static void direct_link_groom(FileData *fd, Groom *groom)
{
groom->adt= newdataadr(fd, groom->adt);
direct_link_animdata(fd, groom->adt);
link_list(fd, &groom->bundles);
- for (GroomBundle *bundle = groom->bundles.first; bundle; bundle->next)
+ for (GroomBundle *bundle = groom->bundles.first; bundle; bundle = bundle->next)
{
link_list(fd, &bundle->sections);
}
@@ -8713,7 +8713,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short
direct_link_workspace(fd, (WorkSpace *)id, main);
break;
case ID_GM:
- direct_link_groom(fd, (Groom *)id, main);
+ direct_link_groom(fd, (Groom *)id);
break;
}
diff --git a/source/blender/makesrna/intern/rna_groom.c b/source/blender/makesrna/intern/rna_groom.c
index 6d5a55ab312..d962a97e17b 100644
--- a/source/blender/makesrna/intern/rna_groom.c
+++ b/source/blender/makesrna/intern/rna_groom.c
@@ -57,7 +57,7 @@
#include "BKE_groom.h"
-static void rna_Groom_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void UNUSED_FUNCTION(rna_Groom_update)(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
WM_main_add_notifier(NC_GROOM | NA_EDITED, NULL);
}
@@ -76,6 +76,8 @@ static void rna_def_groom(BlenderRNA *brna)
/* Animation Data */
rna_def_animdata_common(srna);
+
+ UNUSED_VARS(prop);
}
void RNA_def_groom(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list