Merge branch 'master' into blender2.8

Conflicts:
	source/blender/editors/space_view3d/drawobject.c
This commit is contained in:
Bastien Montagne 2018-06-09 15:18:21 +02:00
commit 70f8eaf1b7
14 changed files with 73 additions and 51 deletions

View File

@ -468,7 +468,7 @@ void modifier_mdef_compact_influences(struct ModifierData *md);
void modifier_path_init(char *path, int path_maxlen, const char *name);
const char *modifier_path_relbase(struct Main *bmain, struct Object *ob);
const char *modifier_path_relbase_from_global(struct Object *ob);
/* wrappers for modifier callbacks that ensure valid normals */

View File

@ -809,6 +809,18 @@ const char *modifier_path_relbase(Main *bmain, Object *ob)
}
}
const char *modifier_path_relbase_from_global(Object *ob)
{
if (G.relbase_valid || ID_IS_LINKED(ob)) {
return ID_BLEND_PATH_FROM_GLOBAL(&ob->id);
}
else {
/* last resort, better then using "" which resolves to the current
* working directory */
return BKE_tempdir_session();
}
}
/* initializes the path with either */
void modifier_path_init(char *path, int path_maxlen, const char *name)
{

View File

@ -86,7 +86,7 @@ float ED_node_grid_size(void);
/* node_relationships.c */
void ED_node_link_intersect_test(struct ScrArea *sa, int test);
void ED_node_link_insert(struct ScrArea *sa);
void ED_node_link_insert(struct Main *bmain, struct ScrArea *sa);
/* node_edit.c */
void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typeinfo);

View File

@ -165,7 +165,7 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
bool do_tag_update = true;
if (node != NULL) {
if (!node_connected_to_output(ntree, node)) {
if (!node_connected_to_output(bmain, ntree, node)) {
do_tag_update = false;
}
}

View File

@ -1102,6 +1102,7 @@ static void node_duplicate_reparent_recursive(bNode *node)
static int node_duplicate_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNode *node, *newnode, *lastnode;
@ -1109,7 +1110,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
const bool keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs");
bool do_tag_update = false;
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
lastnode = ntree->nodes.last;
for (node = ntree->nodes.first; node; node = node->next) {
@ -1186,7 +1187,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
node->flag &= ~NODE_ACTIVE;
nodeSetSelected(newnode, true);
do_tag_update |= (do_tag_update || node_connected_to_output(ntree, newnode));
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode));
}
/* make sure we don't copy new nodes again! */
@ -1522,18 +1523,19 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
static int node_mute_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node;
bool do_tag_update = false;
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
for (node = snode->edittree->nodes.first; node; node = node->next) {
/* Only allow muting of nodes having a mute func! */
if ((node->flag & SELECT) && node->typeinfo->update_internal_links) {
node->flag ^= NODE_MUTED;
snode_update(snode, node);
do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node));
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
}
}
@ -1564,17 +1566,18 @@ void NODE_OT_mute_toggle(wmOperatorType *ot)
static int node_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNode *node, *next;
bool do_tag_update = false;
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
for (node = snode->edittree->nodes.first; node; node = next) {
next = node->next;
if (node->flag & SELECT) {
/* check id user here, nodeFreeNode is called for free dbase too */
do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node));
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
if (node->id)
id_us_min(node->id);
nodeFreeNode(snode->edittree, node);

View File

@ -181,7 +181,7 @@ void NODE_OT_group_edit(wmOperatorType *ot)
/* ******************** Ungroup operator ********************** */
/* returns 1 if its OK */
static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
{
bNodeLink *link, *linkn, *tlink;
bNode *node, *nextnode;
@ -200,7 +200,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
* - ngroup (i.e. the source NodeTree) is left unscathed
* - temp copy. don't change ID usercount
*/
wgroup = ntreeCopyTree_ex(ngroup, G.main, false);
wgroup = ntreeCopyTree_ex(ngroup, bmain, false);
/* Add the nodes into the ntree */
for (node = wgroup->nodes.first; node; node = nextnode) {
@ -257,7 +257,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
bAction *waction;
/* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
waction = wgroup->adt->action = BKE_action_copy(G.main, wgroup->adt->action);
waction = wgroup->adt->action = BKE_action_copy(bmain, wgroup->adt->action);
/* now perform the moving */
BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
@ -272,13 +272,13 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
/* free temp action too */
if (waction) {
BKE_libblock_free(G.main, waction);
BKE_libblock_free(bmain, waction);
wgroup->adt->action = NULL;
}
}
/* free the group tree (takes care of user count) */
BKE_libblock_free(G.main, wgroup);
BKE_libblock_free(bmain, wgroup);
/* restore external links to and from the gnode */
/* note: the nodes have been copied to intermediate wgroup first (so need to use new_node),
@ -354,18 +354,19 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
static int node_group_ungroup_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
const char *node_idname = group_node_idname(C);
bNode *gnode;
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
gnode = node_group_get_active(C, node_idname);
if (!gnode)
return OPERATOR_CANCELLED;
if (gnode->id && node_group_ungroup(snode->edittree, gnode)) {
ntreeUpdateTree(CTX_data_main(C), snode->nodetree);
if (gnode->id && node_group_ungroup(bmain, snode->edittree, gnode)) {
ntreeUpdateTree(bmain, snode->nodetree);
}
else {
BKE_report(op->reports, RPT_WARNING, "Cannot ungroup");

View File

@ -41,6 +41,7 @@ struct ARegion;
struct ARegionType;
struct View2D;
struct bContext;
struct Main;
struct wmWindow;
struct bNode;
struct bNodeSocket;
@ -157,7 +158,7 @@ void NODE_OT_group_edit(struct wmOperatorType *ot);
/* node_relationships.c */
bool node_connected_to_output(struct bNodeTree *ntree, struct bNode *node);
bool node_connected_to_output(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
void NODE_OT_link(struct wmOperatorType *ot);
void NODE_OT_link_make(struct wmOperatorType *ot);

View File

@ -131,9 +131,8 @@ static bool node_group_has_output_dfs(bNode *node)
return false;
}
static bool node_group_has_output(bNode *node)
static bool node_group_has_output(Main *bmain, bNode *node)
{
Main *bmain = G.main;
BLI_assert(node->type == NODE_GROUP);
bNodeTree *ntree = (bNodeTree *)node->id;
if (ntree == NULL) {
@ -143,7 +142,7 @@ static bool node_group_has_output(bNode *node)
return node_group_has_output_dfs(node);
}
bool node_connected_to_output(bNodeTree *ntree, bNode *node)
bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
{
/* Special case for drivers: if node tree has any drivers we assume it is
* always to be tagged for update when node changes. Otherwise we will be
@ -170,7 +169,7 @@ bool node_connected_to_output(bNodeTree *ntree, bNode *node)
return true;
}
if (ntree_check_nodes_connected(ntree, node, current_node) &&
node_group_has_output(current_node))
node_group_has_output(bmain, current_node))
{
return true;
}
@ -313,7 +312,7 @@ static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocke
return true;
}
static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const bool replace)
static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_multiple, const bool replace)
{
bNodeTree *ntree = snode->edittree;
ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list");
@ -390,7 +389,7 @@ static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const
}
if (numlinks > 0) {
ntreeUpdateTree(G.main, ntree);
ntreeUpdateTree(bmain, ntree);
}
BLI_freelistN(nodelist);
@ -582,6 +581,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
bNodeTree *ntree = snode->edittree;
bNodeLinkDrag *nldrag = op->customdata;
@ -620,7 +620,7 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
node_remove_extra_links(snode, link);
if (link->tonode) {
do_tag_update |= (do_tag_update || node_connected_to_output(ntree, link->tonode));
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, link->tonode));
}
}
else {
@ -629,7 +629,7 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
}
ntree->is_updating = false;
ntreeUpdateTree(CTX_data_main(C), ntree);
ntreeUpdateTree(bmain, ntree);
snode_notify(C, snode);
if (do_tag_update) {
snode_dag_update(C, snode);
@ -741,7 +741,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* return 1 when socket clicked */
static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool detach)
static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor[2], bool detach)
{
bNode *node;
bNodeSocket *sock;
@ -775,7 +775,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
* using TEST flag.
*/
oplink->flag &= ~NODE_LINK_TEST;
if (node_connected_to_output(snode->edittree, link->tonode)) {
if (node_connected_to_output(bmain, snode->edittree, link->tonode)) {
oplink->flag |= NODE_LINK_TEST;
}
@ -794,7 +794,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
oplink->fromsock = sock;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
if (node_connected_to_output(snode->edittree, node)) {
if (node_connected_to_output(bmain, snode->edittree, node)) {
oplink->flag |= NODE_LINK_TEST;
}
@ -819,7 +819,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
oplink->next = oplink->prev = NULL;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
if (node_connected_to_output(snode->edittree, link->tonode)) {
if (node_connected_to_output(bmain, snode->edittree, link->tonode)) {
oplink->flag |= NODE_LINK_TEST;
}
@ -842,7 +842,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
oplink->tosock = sock;
oplink->flag |= NODE_LINK_VALID;
oplink->flag &= ~NODE_LINK_TEST;
if (node_connected_to_output(snode->edittree, node)) {
if (node_connected_to_output(bmain, snode->edittree, node)) {
oplink->flag |= NODE_LINK_TEST;
}
@ -855,6 +855,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det
static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
bNodeLinkDrag *nldrag;
@ -865,9 +866,9 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&cursor[0], &cursor[1]);
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
nldrag = node_link_init(snode, cursor, detach);
nldrag = node_link_init(bmain, snode, cursor, detach);
if (nldrag) {
op->customdata = nldrag;
@ -918,12 +919,13 @@ void NODE_OT_link(wmOperatorType *ot)
/* makes a link between selected output and input sockets */
static int node_make_link_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
const bool replace = RNA_boolean_get(op->ptr, "replace");
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
snode_autoconnect(snode, 1, replace);
snode_autoconnect(bmain, snode, 1, replace);
/* deselect sockets after linking */
node_deselect_all_input_sockets(snode, 0);
@ -971,6 +973,7 @@ static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
static int cut_links_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
float mcoords[256][2];
@ -993,7 +996,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
bool found = false;
bNodeLink *link, *next;
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
for (link = snode->edittree->links.first; link; link = next) {
next = link->next;
@ -1004,11 +1007,11 @@ static int cut_links_exec(bContext *C, wmOperator *op)
if (found == false) {
/* TODO(sergey): Why did we kill jobs twice? */
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
found = true;
}
do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, link->tonode));
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, link->tonode));
snode_update(snode, link->tonode);
nodeRemLink(snode->edittree, link);
@ -1833,7 +1836,7 @@ void NODE_OT_insert_offset(wmOperatorType *ot)
}
/* assumes link with NODE_LINKFLAG_HILITE set */
void ED_node_link_insert(ScrArea *sa)
void ED_node_link_insert(Main *bmain, ScrArea *sa)
{
bNode *node, *select;
SpaceNode *snode;
@ -1873,7 +1876,7 @@ void ED_node_link_insert(ScrArea *sa)
snode->iofsd = iofsd;
}
ntreeUpdateTree(G.main, snode->edittree); /* needed for pointers */
ntreeUpdateTree(bmain, snode->edittree); /* needed for pointers */
snode_update(snode, select);
ED_node_tag_update_id(snode->id);
}

View File

@ -82,11 +82,11 @@ static bool node_link_item_compare(bNode *node, NodeLinkItem *item)
return true;
}
static void node_link_item_apply(bNode *node, NodeLinkItem *item)
static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item)
{
if (node->type == NODE_GROUP) {
node->id = (ID *)item->ngroup;
ntreeUpdateTree(G.main, item->ngroup);
ntreeUpdateTree(bmain, item->ngroup);
}
else {
/* nothing to do for now */
@ -191,6 +191,7 @@ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bN
static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to,
int type, NodeLinkItem *item)
{
Main *bmain = CTX_data_main(C);
bNode *node_from;
bNodeSocket *sock_from_tmp;
bNode *node_prev = NULL;
@ -233,7 +234,7 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode *
node_from->locy = node_to->locy - (node_from->typeinfo->height * index);
}
node_link_item_apply(node_from, item);
node_link_item_apply(bmain, node_from, item);
}
nodeSetActive(ntree, node_from);

View File

@ -6429,7 +6429,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (canceled == 0) {
ED_node_post_apply_transform(C, snode->edittree);
ED_node_link_insert(t->sa);
ED_node_link_insert(bmain, t->sa);
}
/* clear link line */

View File

@ -382,6 +382,7 @@ typedef enum ID_Type {
#define ID_CHECK_UNDO(id) ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM) && (GS((id)->name) != ID_WS))
#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : BKE_main_blendfile_path((_bmain)))
#define ID_BLEND_PATH_FROM_GLOBAL(_id) ((_id)->lib ? (_id)->lib->filepath : BKE_main_blendfile_path_from_global())
#define ID_MISSING(_id) (((_id)->tag & LIB_TAG_MISSING) != 0)

View File

@ -431,7 +431,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
}
static DerivedMesh *fluidsim_read_cache(
Main *bmain, Object *ob, DerivedMesh *orgdm,
Object *ob, DerivedMesh *orgdm,
FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
@ -466,7 +466,7 @@ static DerivedMesh *fluidsim_read_cache(
/* offset baked frame */
curFrame += fss->frameOffset;
BLI_path_abs(targetFile, modifier_path_relbase(bmain, ob));
BLI_path_abs(targetFile, modifier_path_relbase_from_global(ob));
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no
/* assign material + flags to new dm
@ -552,7 +552,7 @@ DerivedMesh *fluidsimModifier_do(
/* try to read from cache */
/* if the frame is there, fine, otherwise don't do anything */
if ((result = fluidsim_read_cache(G.main, ob, dm, fluidmd, framenr, useRenderParams)))
if ((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
return result;
return dm;

View File

@ -152,7 +152,7 @@ static void meshcache_do(
/* would be nice if we could avoid doing this _every_ frame */
BLI_strncpy(filepath, mcmd->filepath, sizeof(filepath));
BLI_path_abs(filepath, ID_BLEND_PATH(G.main, (ID *)ob));
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL((ID *)ob));
switch (mcmd->type) {
case MOD_MESHCACHE_TYPE_MDD:

View File

@ -49,9 +49,9 @@
#include "MOD_modifiertypes.h"
#ifdef WITH_OCEANSIM
static void init_cache_data(Main *bmain, Object *ob, struct OceanModifierData *omd)
static void init_cache_data(Object *ob, struct OceanModifierData *omd)
{
const char *relbase = modifier_path_relbase(bmain, ob);
const char *relbase = modifier_path_relbase_from_global(ob);
omd->oceancache = BKE_ocean_init_cache(omd->cachepath, relbase,
omd->bakestart, omd->bakeend, omd->wave_scale,
@ -448,7 +448,7 @@ static DerivedMesh *doOcean(
/* do ocean simulation */
if (omd->cached == true) {
if (!omd->oceancache) {
init_cache_data(G.main, ob, omd);
init_cache_data(ob, omd);
}
BKE_ocean_simulate_cache(omd->oceancache, md->scene->r.cfra);
}