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:
authorGermano <germano.costa@ig.com.br>2017-11-16 20:12:32 +0300
committerGermano <germano.costa@ig.com.br>2017-11-16 20:12:32 +0300
commit88c88c4610260ef3d00420c3e9fc3c1cd56aad14 (patch)
treeb9e49f253fd37c773c2098b583019e2240655885 /source/blender/blenkernel/intern/mball.c
parent562da211c21bc57e35d7b2dba2f36c2472de90a2 (diff)
Fix T51210: Draw Manager: Support for Metaball Drawing
Differential Revision: D2914
Diffstat (limited to 'source/blender/blenkernel/intern/mball.c')
-rw-r--r--source/blender/blenkernel/intern/mball.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index f2c39d6cc72..d5cddf34eb5 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -75,6 +75,8 @@ void BKE_mball_free(MetaBall *mb)
{
BKE_animdata_free((ID *)mb, false);
+ BKE_mball_batch_cache_free(mb);
+
MEM_SAFE_FREE(mb->mat);
BLI_freelistN(&mb->elems);
@@ -120,6 +122,7 @@ void BKE_mball_copy_data(Main *UNUSED(bmain), MetaBall *mb_dst, const MetaBall *
mb_dst->editelems = NULL;
mb_dst->lastelem = NULL;
+ mb_dst->batch_cache = NULL;
}
MetaBall *BKE_mball_copy(Main *bmain, const MetaBall *mb)
@@ -542,3 +545,47 @@ void BKE_mball_eval_geometry(const struct EvaluationContext *UNUSED(eval_ctx),
MetaBall *UNUSED(mball))
{
}
+
+/* Draw Engine */
+
+/* use for draw-manager only. */
+void BKE_mball_element_calc_display_m3x4(float r_scale_xform[3][4],
+ const float obmat[4][4],
+ const float local_pos[3])
+{
+ float world_pos[3], scamat[3][3];
+ mul_v3_m4v3(world_pos, obmat, local_pos);
+ copy_m3_m4(scamat, obmat);
+ {
+ /* Get the normalized inverse matrix to extract only
+ * the scale of Scamat */
+ float iscamat[3][3];
+ invert_m3_m3(iscamat, scamat);
+ normalize_m3(iscamat);
+ mul_m3_m3_post(scamat, iscamat);
+ }
+
+ copy_v3_v3(r_scale_xform[0], scamat[0]);
+ copy_v3_v3(r_scale_xform[1], scamat[1]);
+ copy_v3_v3(r_scale_xform[2], scamat[2]);
+
+ r_scale_xform[0][3] = world_pos[0];
+ r_scale_xform[1][3] = world_pos[1];
+ r_scale_xform[2][3] = world_pos[2];
+}
+
+void (*BKE_mball_batch_cache_dirty_cb)(MetaBall *mb, int mode) = NULL;
+void (*BKE_mball_batch_cache_free_cb)(MetaBall *mb) = NULL;
+
+void BKE_mball_batch_cache_dirty(MetaBall *mb, int mode)
+{
+ if (mb->batch_cache) {
+ BKE_mball_batch_cache_dirty_cb(mb, mode);
+ }
+}
+void BKE_mball_batch_cache_free(MetaBall *mb)
+{
+ if (mb->batch_cache) {
+ BKE_mball_batch_cache_free_cb(mb);
+ }
+}