[Bf-blender-cvs] [1ffd971] viewport_bvh_select: Add/use BKE_object_boundbox_to_worldspace
Julian Eisel
noreply at git.blender.org
Sun Aug 28 16:00:27 CEST 2016
Commit: 1ffd9714b930dbef8059403d69650476f625f554
Author: Julian Eisel
Date: Sun Aug 28 15:59:39 2016 +0200
Branches: viewport_bvh_select
https://developer.blender.org/rB1ffd9714b930dbef8059403d69650476f625f554
Add/use BKE_object_boundbox_to_worldspace
===================================================================
M source/blender/blenkernel/BKE_object.h
M source/blender/blenkernel/intern/object.c
M source/blender/editors/space_view3d/view3d_bvh.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 1498fc8..f668298 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -150,6 +150,10 @@ struct BoundBox *BKE_object_boundbox_get(struct Object *ob);
void BKE_object_drawboundbox_get(
const struct Scene *scene, const struct Object *ob,
struct BoundBox *r_bb);
+void BKE_object_boundbox_to_worldspace(
+ const struct Object *ob, const float pixelsize,
+ const struct BoundBox *in_localspace,
+ struct BoundBox *r_out_worldspace);
void BKE_object_dimensions_get(struct Object *ob, float vec[3]);
void BKE_object_dimensions_set(struct Object *ob, const float value[3]);
void BKE_object_boundbox_flag(struct Object *ob, int flag, const bool set);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 541f004..b7a2500 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2344,6 +2344,29 @@ void BKE_object_drawboundbox_get(
}
}
+/**
+ * Transform a (draw-) bounding box from local into world space.
+ * \a in_localspace and *r_out_worldspace are allowed to be the same.
+ *
+ * \param pixelsize: Value of #ED_view3d_pixel_size.
+ */
+void BKE_object_boundbox_to_worldspace(
+ const Object *ob, const float pixelsize,
+ const BoundBox *in_localspace,
+ BoundBox *r_out_worldspace)
+{
+ for (int i = 0; i < 8; i++) {
+ if (ob->type == OB_LAMP) {
+ /* for lamps, only use location and zoom independent size */
+ mul_v3_v3fl(r_out_worldspace->vec[i], in_localspace->vec[i], pixelsize);
+ add_v3_v3(r_out_worldspace->vec[i], ob->obmat[3]);
+ }
+ else {
+ mul_v3_m4v3(r_out_worldspace->vec[i], (float (*)[4])ob->obmat, in_localspace->vec[i]);
+ }
+ }
+}
+
/* used to temporally disable/enable boundbox */
void BKE_object_boundbox_flag(Object *ob, int flag, const bool set)
{
diff --git a/source/blender/editors/space_view3d/view3d_bvh.c b/source/blender/editors/space_view3d/view3d_bvh.c
index f99ff3e..f1063d9 100644
--- a/source/blender/editors/space_view3d/view3d_bvh.c
+++ b/source/blender/editors/space_view3d/view3d_bvh.c
@@ -50,18 +50,7 @@ static void bvh_objects_insert(View3D *v3d, const RegionView3D *rv3d, const Scen
ob = base->object;
if (BASE_SELECTABLE(v3d, base)) {
BKE_object_drawboundbox_get(scene, ob, &bb);
-
- for (int j = 0; j < 8; j++) {
- if (ob->type == OB_LAMP) {
- /* for lamps, only use location and zoom independent size */
- const float pixelsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]);
- mul_v3_fl(bb.vec[j], pixelsize);
- add_v3_v3(bb.vec[j], ob->obmat[3]);
- }
- else {
- mul_m4_v3(ob->obmat, bb.vec[j]);
- }
- }
+ BKE_object_boundbox_to_worldspace(ob, ED_view3d_pixel_size(rv3d, ob->obmat[3]), &bb, &bb);
BLI_bvhtree_insert(v3d->bvhtree, i++, &bb.vec[0][0], 8);
}
More information about the Bf-blender-cvs
mailing list