fix for crash when moving frames about in the node space, was possible to move a node into its own child frame (causing recursive parent loop).
also some minor code cleanup.
This commit is contained in:
@@ -359,6 +359,7 @@ void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node);
|
||||
|
||||
void nodeToView(struct bNode *node, float x, float y, float *rx, float *ry);
|
||||
void nodeFromView(struct bNode *node, float x, float y, float *rx, float *ry);
|
||||
int nodeAttachNodeCheck(struct bNode *node, struct bNode *parent);
|
||||
void nodeAttachNode(struct bNode *node, struct bNode *parent);
|
||||
void nodeDetachNode(struct bNode *node);
|
||||
|
||||
|
||||
@@ -592,9 +592,25 @@ void nodeFromView(bNode *node, float x, float y, float *rx, float *ry)
|
||||
}
|
||||
}
|
||||
|
||||
int nodeAttachNodeCheck(bNode *node, bNode *parent)
|
||||
{
|
||||
bNode *parent_recurse;
|
||||
for (parent_recurse = node; parent_recurse; parent_recurse = parent_recurse->parent) {
|
||||
if (parent_recurse == parent) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void nodeAttachNode(bNode *node, bNode *parent)
|
||||
{
|
||||
float locx, locy;
|
||||
|
||||
BLI_assert(parent->type == NODE_FRAME);
|
||||
BLI_assert(nodeAttachNodeCheck(parent, node) == FALSE);
|
||||
|
||||
nodeToView(node, 0.0f, 0.0f, &locx, &locy);
|
||||
|
||||
node->parent = parent;
|
||||
@@ -607,6 +623,9 @@ void nodeDetachNode(struct bNode *node)
|
||||
float locx, locy;
|
||||
|
||||
if (node->parent) {
|
||||
|
||||
BLI_assert(node->parent->type == NODE_FRAME);
|
||||
|
||||
/* transform to view space */
|
||||
nodeToView(node, 0.0f, 0.0f, &locx, &locy);
|
||||
node->locx = locx;
|
||||
|
||||
@@ -996,9 +996,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
float alpha;
|
||||
|
||||
/* skip if out of view */
|
||||
if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
|
||||
node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) {
|
||||
|
||||
if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
|
||||
uiEndBlock(C, node->block);
|
||||
node->block = NULL;
|
||||
return;
|
||||
|
||||
@@ -681,9 +681,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
|
||||
nodeShaderSynchronizeID(node, 0);
|
||||
|
||||
/* skip if out of view */
|
||||
if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
|
||||
node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax)
|
||||
{
|
||||
if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
|
||||
uiEndBlock(C, node->block);
|
||||
node->block = NULL;
|
||||
return;
|
||||
|
||||
@@ -762,7 +762,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r
|
||||
/* ************************** Node generic ************** */
|
||||
|
||||
/* is rct in visible part of node? */
|
||||
static bNode *visible_node(SpaceNode *snode, rctf *rct)
|
||||
static bNode *visible_node(SpaceNode *snode, const rctf *rct)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
|
||||
@@ -1147,17 +1147,26 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
for (node = ntree->nodes.last; node; node = node->prev) {
|
||||
if (node->flag & NODE_SELECT) {
|
||||
if (node->parent == NULL) {
|
||||
/* attach all unparented nodes */
|
||||
nodeAttachNode(node, frame);
|
||||
/* disallow moving a parent into its child */
|
||||
if (nodeAttachNodeCheck(frame, node) == FALSE) {
|
||||
/* attach all unparented nodes */
|
||||
nodeAttachNode(node, frame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* attach nodes which share parent with the frame */
|
||||
for (parent = frame->parent; parent; parent = parent->parent)
|
||||
if (parent == node->parent)
|
||||
for (parent = frame->parent; parent; parent = parent->parent) {
|
||||
if (parent == node->parent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
nodeDetachNode(node);
|
||||
nodeAttachNode(node, frame);
|
||||
/* disallow moving a parent into its child */
|
||||
if (nodeAttachNodeCheck(frame, node) == FALSE) {
|
||||
nodeDetachNode(node);
|
||||
nodeAttachNode(node, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ int initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, struc
|
||||
void postTrans (struct bContext *C, TransInfo *t);
|
||||
void resetTransRestrictions(TransInfo *t);
|
||||
|
||||
void drawLine(TransInfo *t, float *center, float *dir, char axis, short options);
|
||||
void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options);
|
||||
|
||||
void drawNonPropEdge(const struct bContext *C, TransInfo *t);
|
||||
|
||||
|
||||
@@ -923,7 +923,7 @@ void recalcData(TransInfo *t)
|
||||
}
|
||||
}
|
||||
|
||||
void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
|
||||
void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
|
||||
{
|
||||
float v1[3], v2[3], v3[3];
|
||||
unsigned char col[3], col2[3];
|
||||
@@ -1017,15 +1017,10 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
|
||||
t->total = 0;
|
||||
|
||||
t->val = 0.0f;
|
||||
|
||||
t->vec[0] =
|
||||
t->vec[1] =
|
||||
t->vec[2] = 0.0f;
|
||||
|
||||
t->center[0] =
|
||||
t->center[1] =
|
||||
t->center[2] = 0.0f;
|
||||
|
||||
zero_v3(t->vec);
|
||||
zero_v3(t->center);
|
||||
|
||||
unit_m3(t->mat);
|
||||
|
||||
/* if there's an event, we're modal */
|
||||
|
||||
Reference in New Issue
Block a user