svn merge ^/trunk/blender -r48681:48691

This commit is contained in:
Campbell Barton 2012-07-06 20:28:35 +00:00
commit eab80a40df
3 changed files with 47 additions and 30 deletions

@ -352,10 +352,11 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma); static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma);
/* recursive handling for material nodetree drivers */ /* recursive handling for material nodetree drivers */
static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree) static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree, Material *rootma)
{ {
bNode *n; bNode *n;
Material *ma;
/* nodetree itself */ /* nodetree itself */
if (ntree->adt) { if (ntree->adt) {
dag_add_driver_relation(ntree->adt, dag, node, 1); dag_add_driver_relation(ntree->adt, dag, node, 1);
@ -364,10 +365,13 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *
/* nodetree's nodes... */ /* nodetree's nodes... */
for (n = ntree->nodes.first; n; n = n->next) { for (n = ntree->nodes.first; n; n = n->next) {
if (n->id && GS(n->id->name) == ID_MA) { if (n->id && GS(n->id->name) == ID_MA) {
dag_add_material_driver_relations(dag, node, (Material *)n->id); ma = (Material *)n->id;
if (ma != rootma) {
dag_add_material_driver_relations(dag, node, ma);
}
} }
else if (n->type == NODE_GROUP && n->id) { else if (n->type == NODE_GROUP && n->id) {
dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id); dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id, rootma);
} }
} }
} }
@ -386,7 +390,7 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat
/* material's nodetree */ /* material's nodetree */
if (ma->nodetree) { if (ma->nodetree) {
dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree); dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree, ma);
} }
} }

@ -1056,10 +1056,11 @@ int material_in_material(Material *parmat, Material *mat)
/* ****************** */ /* ****************** */
/* Update drivers for materials in a nodetree */ /* Update drivers for materials in a nodetree */
static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime) static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime, Material *rootma)
{ {
bNode *node; bNode *node;
Material *ma;
/* nodetree itself */ /* nodetree itself */
if (ntree->adt && ntree->adt->drivers.first) { if (ntree->adt && ntree->adt->drivers.first) {
BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS); BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS);
@ -1069,10 +1070,14 @@ static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float c
for (node = ntree->nodes.first; node; node = node->next) { for (node = ntree->nodes.first; node; node = node->next) {
if (node->id && GS(node->id->name) == ID_MA) { if (node->id && GS(node->id->name) == ID_MA) {
/* TODO: prevent infinite recursion here... */ /* TODO: prevent infinite recursion here... */
material_drivers_update(scene, (Material *)node->id, ctime); ma = (Material *)node->id;
if (ma != rootma) {
material_drivers_update(scene, ma, ctime);
}
} }
else if (node->type == NODE_GROUP && node->id) { else if (node->type == NODE_GROUP && node->id) {
material_node_drivers_update(scene, (bNodeTree *)node->id, ctime); material_node_drivers_update(scene, (bNodeTree *)node->id,
ctime, rootma);
} }
} }
} }
@ -1094,7 +1099,7 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
/* nodes */ /* nodes */
if (ma->nodetree) { if (ma->nodetree) {
material_node_drivers_update(scene, ma->nodetree, ctime); material_node_drivers_update(scene, ma->nodetree, ctime, ma);
} }
} }

@ -38,6 +38,9 @@
#include "bmesh.h" #include "bmesh.h"
#define HULL_EPSILON_FLT 0.0001f #define HULL_EPSILON_FLT 0.0001f
/* values above 0.0001 cause errors, see below for details, don't increase
* without checking against bug [#32027] */
#define HULL_EPSILON_DOT_FLT 0.00000001f
/* Internal operator flags */ /* Internal operator flags */
typedef enum { typedef enum {
@ -72,23 +75,23 @@ typedef struct HullBoundaryEdge {
/*************************** Boundary Edges ***************************/ /*************************** Boundary Edges ***************************/
static int edge_match(BMVert *e1_0, BMVert *e1_1, BMVert *e2[2]) static int edge_match(BMVert *e1_v1, BMVert *e1_v2, BMVert *e2[2])
{ {
return (e1_0 == e2[0] && e1_1 == e2[1]) || return (e1_v1 == e2[0] && e1_v2 == e2[1]) ||
(e1_0 == e2[1] && e1_1 == e2[0]); (e1_v1 == e2[1] && e1_v2 == e2[0]);
} }
/* Returns true if the edge (e1, e2) is already in edges; that edge is /* Returns true if the edge (e1, e2) is already in edges; that edge is
* deleted here as well. if not found just returns 0 */ * deleted here as well. if not found just returns 0 */
static int check_for_dup(ListBase *edges, BLI_mempool *pool, static int check_for_dup(ListBase *edges, BLI_mempool *pool,
BMVert *e1, BMVert *e2) BMVert *v1, BMVert *v2)
{ {
HullBoundaryEdge *e, *next; HullBoundaryEdge *e, *e_next;
for (e = edges->first; e; e = next) { for (e = edges->first; e; e = e_next) {
next = e->next; e_next = e->next;
if (edge_match(e1, e2, e->v)) { if (edge_match(v1, v2, e->v)) {
/* remove the interior edge */ /* remove the interior edge */
BLI_remlink(edges, e); BLI_remlink(edges, e);
BLI_mempool_free(pool, e); BLI_mempool_free(pool, e);
@ -102,17 +105,17 @@ static int check_for_dup(ListBase *edges, BLI_mempool *pool,
static void expand_boundary_edges(ListBase *edges, BLI_mempool *edge_pool, static void expand_boundary_edges(ListBase *edges, BLI_mempool *edge_pool,
const HullTriangle *t) const HullTriangle *t)
{ {
HullBoundaryEdge *new; HullBoundaryEdge *e_new;
int i; int i;
/* Insert each triangle edge into the boundary list; if any of /* Insert each triangle edge into the boundary list; if any of
* its edges are already in there, remove the edge entirely */ * its edges are already in there, remove the edge entirely */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (!check_for_dup(edges, edge_pool, t->v[i], t->v[(i + 1) % 3])) { if (!check_for_dup(edges, edge_pool, t->v[i], t->v[(i + 1) % 3])) {
new = BLI_mempool_calloc(edge_pool); e_new = BLI_mempool_calloc(edge_pool);
new->v[0] = t->v[i]; e_new->v[0] = t->v[i];
new->v[1] = t->v[(i + 1) % 3]; e_new->v[1] = t->v[(i + 1) % 3];
BLI_addtail(edges, new); BLI_addtail(edges, e_new);
} }
} }
} }
@ -144,12 +147,16 @@ static int hull_point_tri_side(const HullTriangle *t, const float co[3])
{ {
/* Added epsilon to fix bug [#31941], improves output when some /* Added epsilon to fix bug [#31941], improves output when some
* vertices are nearly coplanar. Might need further tweaking for * vertices are nearly coplanar. Might need further tweaking for
* other cases though. */ * other cases though.
* ...
* Update: epsilon of 0.0001 causes [#32027], use HULL_EPSILON_DOT_FLT
* and give it a much smaller value
* */
float p[3], d; float p[3], d;
sub_v3_v3v3(p, co, t->v[0]->co); sub_v3_v3v3(p, co, t->v[0]->co);
d = dot_v3v3(t->no, p); d = dot_v3v3(t->no, p);
if (d < -HULL_EPSILON_FLT) return -1; if (d < -HULL_EPSILON_DOT_FLT) return -1;
else if (d > HULL_EPSILON_FLT) return 1; else if (d > HULL_EPSILON_DOT_FLT) return 1;
else return 0; else return 0;
} }
@ -179,7 +186,7 @@ static void add_point(BMesh *bm, GHash *hull_triangles, BLI_mempool *hull_pool,
BLI_mempool *edge_pool, GHash *outside, BMVert *v) BLI_mempool *edge_pool, GHash *outside, BMVert *v)
{ {
ListBase edges = {NULL, NULL}; ListBase edges = {NULL, NULL};
HullBoundaryEdge *e, *next; HullBoundaryEdge *e, *e_next;
GHashIterator iter; GHashIterator iter;
GHASH_ITER (iter, outside) { GHASH_ITER (iter, outside) {
@ -198,8 +205,8 @@ static void add_point(BMesh *bm, GHash *hull_triangles, BLI_mempool *hull_pool,
} }
/* Fill hole boundary with triangles to new point */ /* Fill hole boundary with triangles to new point */
for (e = edges.first; e; e = next) { for (e = edges.first; e; e = e_next) {
next = e->next; e_next = e->next;
hull_add_triangle(bm, hull_triangles, hull_pool, e->v[0], e->v[1], v); hull_add_triangle(bm, hull_triangles, hull_pool, e->v[0], e->v[1], v);
BLI_mempool_free(edge_pool, e); BLI_mempool_free(edge_pool, e);
} }
@ -356,7 +363,8 @@ static void hull_add_tetrahedron(BMesh *bm, GHash *hull_triangles, BLI_mempool *
{0, 1, 2}, {0, 1, 2},
{0, 2, 3}, {0, 2, 3},
{1, 0, 3}, {1, 0, 3},
{2, 1, 3}}; {2, 1, 3}
};
/* Calculate center */ /* Calculate center */
zero_v3(center); zero_v3(center);