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:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-07-10 14:24:06 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-07-10 14:24:06 +0400
commit5e1d450b90c731444164c2754e7fdad86bd831ab (patch)
tree3fe79785c94eae84fe148f3adfbcd025b11a62f8 /source/blender/blenkernel/intern/mball.c
parent3f9629a4c74685c0a13b8cdfb34768f7b6864d1e (diff)
Fix #36076: Metaballs as particles with particle texture (size influence) crashes Blender
Issue was caused by size influence affecting on object's matrix, which is nice by it's own. But mball code was using ob->size to check whether it's zero-sized object or not, but then was using ob->obmat to scale the meta elements. This lead to situation when zero-sized elements were trying to tessellate, which is for sure a really bad idea.
Diffstat (limited to 'source/blender/blenkernel/intern/mball.c')
-rw-r--r--source/blender/blenkernel/intern/mball.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 55b1a65a73e..3ccf5038d87 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -1646,6 +1646,14 @@ BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z)
v[2] = z;
}
+/* TODO(sergey): Perhaps it could be general utility function in mathutils. */
+static bool has_zero_axis_m4(float matrix[4][4])
+{
+ return len_squared_v3(matrix[0]) < FLT_EPSILON ||
+ len_squared_v3(matrix[1]) < FLT_EPSILON ||
+ len_squared_v3(matrix[2]) < FLT_EPSILON;
+}
+
static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return totsize */
{
Scene *sce_iter = scene;
@@ -1694,13 +1702,13 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
/* when metaball object has zero scale, then MetaElem to this MetaBall
* will not be put to mainb array */
- if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) {
+ if (has_zero_axis_m4(bob->obmat)) {
zero_size = 1;
}
else if (bob->parent) {
struct Object *pob = bob->parent;
while (pob) {
- if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) {
+ if (has_zero_axis_m4(pob->obmat)) {
zero_size = 1;
break;
}