Merge branch 'master' into refactor-mesh-position-generic

This commit is contained in:
Hans Goudey 2023-01-02 13:51:46 -05:00
commit 0fe2828c1c
6 changed files with 55 additions and 10 deletions

View File

@ -1675,8 +1675,11 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
continue;
}
OperationCode target_op = driver_targets_bbone ? OperationCode::BONE_SEGMENTS :
OperationCode::BONE_LOCAL;
OperationCode target_op = OperationCode::BONE_LOCAL;
if (driver_targets_bbone) {
target_op = check_pchan_has_bbone_segments(object, pchan) ? OperationCode::BONE_SEGMENTS :
OperationCode::BONE_DONE;
}
OperationKey bone_key(&object->id, NodeType::BONE, pchan->name, target_op);
add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone");
}

View File

@ -105,8 +105,7 @@ void evaluate_node(const DepsgraphEvalState *state, OperationNode *operation_nod
* times.
* This is a thread-safe modification as the node's flags are only read for a non-scheduled nodes
* and this node has been scheduled. */
operation_node->flag &= ~(DEPSOP_FLAG_DIRECTLY_MODIFIED | DEPSOP_FLAG_NEEDS_UPDATE |
DEPSOP_FLAG_USER_MODIFIED);
operation_node->flag &= ~DEPSOP_FLAG_CLEAR_ON_EVAL;
}
void deg_task_run_func(TaskPool *pool, void *taskdata)
@ -270,6 +269,10 @@ void schedule_node(DepsgraphEvalState *state,
bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t *)&node->scheduled, uint8_t(true));
if (!is_scheduled) {
if (node->is_noop()) {
/* Clear flags to avoid affecting subsequent update propagation.
* For normal nodes these are cleared when it is evaluated. */
node->flag &= ~DEPSOP_FLAG_CLEAR_ON_EVAL;
/* skip NOOP node, schedule children right away */
schedule_children(state, node, schedule_fn);
}

View File

@ -224,6 +224,10 @@ enum OperationFlag {
/* Set of flags which gets flushed along the relations. */
DEPSOP_FLAG_FLUSH = (DEPSOP_FLAG_USER_MODIFIED),
/* Set of flags which get cleared upon evaluation. */
DEPSOP_FLAG_CLEAR_ON_EVAL = (DEPSOP_FLAG_DIRECTLY_MODIFIED | DEPSOP_FLAG_NEEDS_UPDATE |
DEPSOP_FLAG_USER_MODIFIED),
};
/* Atomic Operation - Base type for all operations */

View File

@ -83,6 +83,8 @@ typedef struct PoseBlendData {
char headerstr[UI_MAX_DRAW_STR];
} PoseBlendData;
static void poselib_blend_flip_pose(bContext *C, wmOperator *op);
/* Makes a copy of the current pose for restoration purposes - doesn't do constraints currently */
static void poselib_backup_posecopy(PoseBlendData *pbd)
{
@ -178,7 +180,7 @@ static void poselib_blend_set_factor(PoseBlendData *pbd, const float new_factor)
}
/* Return operator return value. */
static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const wmEvent *event)
static int poselib_blend_handle_event(bContext *C, wmOperator *op, const wmEvent *event)
{
PoseBlendData *pbd = op->customdata;
@ -225,7 +227,9 @@ static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const
pbd->needs_redraw = true;
break;
/* TODO(Sybren): use better UI for slider. */
case EVT_FKEY:
poselib_blend_flip_pose(C, op);
break;
}
return OPERATOR_RUNNING_MODAL;
@ -276,6 +280,30 @@ static bAction *flip_pose(bContext *C, Object *ob, bAction *action)
return action_copy;
}
/* Flip the target pose the interactive blend operator is currently using. */
static void poselib_blend_flip_pose(bContext *C, wmOperator *op)
{
PoseBlendData *pbd = op->customdata;
bAction *old_action = pbd->act;
bAction *new_action = flip_pose(C, pbd->ob, old_action);
/* Before flipping over to the other side, this side needs to be restored. */
BKE_pose_backup_restore(pbd->pose_backup);
BKE_pose_backup_free(pbd->pose_backup);
pbd->pose_backup = NULL;
if (pbd->free_action) {
BKE_id_free(NULL, old_action);
}
pbd->free_action = true;
pbd->act = new_action;
pbd->needs_redraw = true;
/* Refresh the pose backup to use the flipped bones. */
poselib_backup_posecopy(pbd);
}
/* Return true on success, false if the context isn't suitable. */
static bool poselib_blend_init_data(bContext *C, wmOperator *op, const wmEvent *event)
{
@ -461,7 +489,11 @@ static int poselib_blend_modal(bContext *C, wmOperator *op, const wmEvent *event
strcpy(tab_string, TIP_("[Tab] - Show blended pose"));
}
BLI_snprintf(status_string, sizeof(status_string), "%s | %s", tab_string, slider_string);
BLI_snprintf(status_string,
sizeof(status_string),
"[F] - Flip pose | %s | %s",
tab_string,
slider_string);
ED_workspace_status_text(C, status_string);
poselib_blend_apply(C, op);

View File

@ -75,10 +75,13 @@ typedef struct tSlider {
/** Last mouse cursor position used for mouse movement delta calculation. */
float last_cursor[2];
/** Enable range beyond 0-100%. */
/** Enable range beyond 0-100%.
* This is set by the code that uses the slider, as not all operations support
* extrapolation. */
bool allow_overshoot;
/** Allow overshoot or clamp between 0% and 100%. */
/** Allow overshoot or clamp between 0% and 100%.
* This is set by the artist while using the slider. */
bool overshoot;
/** Move factor in 10% steps. */

View File

@ -355,7 +355,7 @@ class Executor {
this->ensure_thread_locals();
/* Construct all node states in parallel. */
threading::parallel_for(nodes.index_range(), 256, [&](const IndexRange range) {
LinearAllocator<> &allocator = this->get_main_or_local_allocator();
LinearAllocator<> &allocator = thread_locals_->local().allocator;
construct_node_range(range, allocator);
});
}