Merge branch 'master' into blender2.8

This commit is contained in:
Sergey Sharybin 2017-09-14 16:16:14 +05:00
commit 75f36266df
16 changed files with 304 additions and 98 deletions

View File

@ -33,7 +33,7 @@ def bake_action(
obj,
*,
action, frames,
**kwargs,
**kwargs
):
"""
:arg obj: Object to bake.
@ -62,7 +62,7 @@ def bake_action_objects(
object_action_pairs,
*,
frames,
**kwargs,
**kwargs
):
"""
A version of :func:`bake_action_objects_iter` that takes frames and returns the output.
@ -82,7 +82,7 @@ def bake_action_objects(
def bake_action_objects_iter(
object_action_pairs,
**kwargs,
**kwargs
):
"""
An coroutine that bakes actions for multiple objects.
@ -122,7 +122,7 @@ def bake_action_iter(
do_visual_keying=True,
do_constraint_clear=False,
do_parents_clear=False,
do_clean=False,
do_clean=False
):
"""
An coroutine that bakes action for a single object.

View File

@ -32,6 +32,7 @@
* \ingroup bke
*/
struct EvaluationContext;
struct ImageUser;
struct Image;
struct ListBase;
@ -233,6 +234,12 @@ float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline, struct Mas
int width, int height,
unsigned int *tot_feather_point);
void BKE_mask_layer_evaluate_animation(struct MaskLayer *masklay, const float ctime);
void BKE_mask_layer_evaluate_deform(struct MaskLayer *masklay, const float ctime);
void BKE_mask_eval_animation(struct EvaluationContext *eval_ctx, struct Mask *mask);
void BKE_mask_eval_update(struct EvaluationContext *eval_ctx, struct Mask *mask);
/* mask_rasterize.c */
struct MaskRasterHandle;
typedef struct MaskRasterHandle MaskRasterHandle;

View File

@ -1179,17 +1179,6 @@ void BKE_mask_point_parent_matrix_get(MaskSplinePoint *point, float ctime, float
}
}
static void mask_evaluate_apply_point_parent(MaskSplinePoint *point, float ctime)
{
float parent_matrix[3][3];
BKE_mask_point_parent_matrix_get(point, ctime, parent_matrix);
mul_m3_v2(parent_matrix, point->bezt.vec[0]);
mul_m3_v2(parent_matrix, point->bezt.vec[1]);
mul_m3_v2(parent_matrix, point->bezt.vec[2]);
}
static void mask_calc_point_handle(MaskSplinePoint *point, MaskSplinePoint *point_prev, MaskSplinePoint *point_next)
{
BezTriple *bezt = &point->bezt;
@ -1405,80 +1394,12 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline)
void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe)
{
/* animation if available */
/* Animation if available. */
if (do_newframe) {
MaskLayerShape *masklay_shape_a;
MaskLayerShape *masklay_shape_b;
int found;
if ((found = BKE_mask_layer_shape_find_frame_range(masklay, ctime,
&masklay_shape_a, &masklay_shape_b)))
{
if (found == 1) {
#if 0
printf("%s: exact %d %d (%d)\n", __func__, (int)ctime, BLI_listbase_count(&masklay->splines_shapes),
masklay_shape_a->frame);
#endif
BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a);
}
else if (found == 2) {
float w = masklay_shape_b->frame - masklay_shape_a->frame;
#if 0
printf("%s: tween %d %d (%d %d)\n", __func__, (int)ctime, BLI_listbase_count(&masklay->splines_shapes),
masklay_shape_a->frame, masklay_shape_b->frame);
#endif
BKE_mask_layer_shape_to_mask_interp(masklay, masklay_shape_a, masklay_shape_b,
(ctime - masklay_shape_a->frame) / w);
}
else {
/* always fail, should never happen */
BLI_assert(found == 2);
}
}
}
/* animation done... */
BKE_mask_layer_calc_handles(masklay);
/* update deform */
{
MaskSpline *spline;
for (spline = masklay->splines.first; spline; spline = spline->next) {
int i;
bool need_handle_recalc = false;
BKE_mask_spline_ensure_deform(spline);
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
MaskSplinePoint *point_deform = &spline->points_deform[i];
BKE_mask_point_free(point_deform);
*point_deform = *point;
point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
mask_evaluate_apply_point_parent(point_deform, ctime);
if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
need_handle_recalc = true;
}
}
/* if the spline has auto or vector handles, these need to be recalculated after deformation */
if (need_handle_recalc) {
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point_deform = &spline->points_deform[i];
if (ELEM(point_deform->bezt.h1, HD_AUTO, HD_VECT)) {
BKE_mask_calc_handle_point(spline, point_deform);
}
}
}
/* end extra calc handles loop */
}
BKE_mask_layer_evaluate_animation(masklay, ctime);
}
/* Update deform. */
BKE_mask_layer_evaluate_deform(masklay, ctime);
}
void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe)

View File

@ -42,8 +42,11 @@
#include "DNA_mask_types.h"
#include "BKE_curve.h"
#include "BKE_global.h"
#include "BKE_mask.h"
#include "DEG_depsgraph.h"
unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int height)
{
@ -810,3 +813,111 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point,
return diff_points;
}
static void mask_evaluate_apply_point_parent(MaskSplinePoint *point, float ctime)
{
float parent_matrix[3][3];
BKE_mask_point_parent_matrix_get(point, ctime, parent_matrix);
mul_m3_v2(parent_matrix, point->bezt.vec[0]);
mul_m3_v2(parent_matrix, point->bezt.vec[1]);
mul_m3_v2(parent_matrix, point->bezt.vec[2]);
}
void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
{
/* animation if available */
MaskLayerShape *masklay_shape_a;
MaskLayerShape *masklay_shape_b;
int found;
if ((found = BKE_mask_layer_shape_find_frame_range(
masklay, ctime, &masklay_shape_a, &masklay_shape_b)))
{
if (found == 1) {
#if 0
printf("%s: exact %d %d (%d)\n",
__func__,
(int)ctime,
BLI_listbase_count(&masklay->splines_shapes),
masklay_shape_a->frame);
#endif
BKE_mask_layer_shape_to_mask(masklay, masklay_shape_a);
}
else if (found == 2) {
float w = masklay_shape_b->frame - masklay_shape_a->frame;
#if 0
printf("%s: tween %d %d (%d %d)\n",
__func__,
(int)ctime,
BLI_listbase_count(&masklay->splines_shapes),
masklay_shape_a->frame, masklay_shape_b->frame);
#endif
BKE_mask_layer_shape_to_mask_interp(
masklay,
masklay_shape_a, masklay_shape_b,
(ctime - masklay_shape_a->frame) / w);
}
else {
/* always fail, should never happen */
BLI_assert(found == 2);
}
}
}
void BKE_mask_layer_evaluate_deform(MaskLayer *masklay, const float ctime)
{
BKE_mask_layer_calc_handles(masklay);
for (MaskSpline *spline = masklay->splines.first;
spline != NULL;
spline = spline->next)
{
bool need_handle_recalc = false;
BKE_mask_spline_ensure_deform(spline);
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
MaskSplinePoint *point_deform = &spline->points_deform[i];
BKE_mask_point_free(point_deform);
*point_deform = *point;
point_deform->uw = point->uw ? MEM_dupallocN(point->uw) : NULL;
mask_evaluate_apply_point_parent(point_deform, ctime);
if (ELEM(point->bezt.h1, HD_AUTO, HD_VECT)) {
need_handle_recalc = true;
}
}
/* if the spline has auto or vector handles, these need to be
* recalculated after deformation.
*/
if (need_handle_recalc) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point_deform = &spline->points_deform[i];
if (ELEM(point_deform->bezt.h1, HD_AUTO, HD_VECT)) {
BKE_mask_calc_handle_point(spline, point_deform);
}
}
}
/* end extra calc handles loop */
}
}
#define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
void BKE_mask_eval_animation(struct EvaluationContext *eval_ctx, Mask *mask)
{
DEBUG_PRINT("%s on %s (%p)\n", __func__, mask->id.name, mask);
for (MaskLayer *mask_layer = mask->masklayers.first;
mask_layer != NULL;
mask_layer = mask_layer->next)
{
BKE_mask_layer_evaluate_animation(mask_layer, eval_ctx->ctime);
}
}
void BKE_mask_eval_update(struct EvaluationContext *eval_ctx, Mask *mask)
{
DEBUG_PRINT("%s on %s (%p)\n", __func__, mask->id.name, mask);
for (MaskLayer *mask_layer = mask->masklayers.first;
mask_layer != NULL;
mask_layer = mask_layer->next)
{
BKE_mask_layer_evaluate_deform(mask_layer, eval_ctx->ctime);
}
}

View File

@ -1658,8 +1658,6 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
* in the future this should handle updates for all datablocks, not
* only objects and scenes. - brecht */
DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph_legacy, scene);
/* TODO(sergey): This is to beocme a node in new depsgraph. */
BKE_mask_update_scene(bmain, scene);
/* update sound system animation (TODO, move to depsgraph) */
BKE_sound_update_scene(bmain, scene);
@ -1703,8 +1701,6 @@ void BKE_scene_update_for_newframe(EvaluationContext *eval_ctx, Main *bmain, Sce
for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set)
DEG_scene_relations_update(bmain, sce_iter);
BKE_mask_evaluate_all_masks(bmain, ctime, true);
/* Update animated cache files for modifiers. */
BKE_cachefile_update_frame(bmain, sce, ctime, (((double)sce->r.frs_sec) / (double)sce->r.frs_sec_base));

View File

@ -39,6 +39,8 @@
#include "BLI_polyfill2d.h"
#include "BLI_polyfill2d_beautify.h"
#include "BLI_linklist.h"
#include "BLI_edgehash.h"
#include "BLI_heap.h"
#include "bmesh.h"
#include "bmesh_tools.h"
@ -1474,3 +1476,129 @@ void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptri
#undef USE_TESSFACE_SPEEDUP
}
/**
* A version of #BM_mesh_calc_tessellation that avoids degenerate triangles.
*/
void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot)
{
/* this assumes all faces can be scan-filled, which isn't always true,
* worst case we over alloc a little which is acceptable */
#ifndef NDEBUG
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
#endif
BMIter iter;
BMFace *efa;
int i = 0;
MemArena *pf_arena = NULL;
/* use_beauty */
Heap *pf_heap = NULL;
EdgeHash *pf_ehash = NULL;
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* don't consider two-edged faces */
if (UNLIKELY(efa->len < 3)) {
/* do nothing */
}
else if (efa->len == 3) {
BMLoop *l;
BMLoop **l_ptr = looptris[i++];
l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa);
l_ptr[1] = l = l->next;
l_ptr[2] = l->next;
}
else if (efa->len == 4) {
BMLoop *l_v1 = BM_FACE_FIRST_LOOP(efa);
BMLoop *l_v2 = l_v1->next;
BMLoop *l_v3 = l_v2->next;
BMLoop *l_v4 = l_v1->prev;
const bool split_24 = (BM_verts_calc_rotate_beauty(l_v1->v, l_v2->v, l_v3->v, l_v4->v, 0, 0) > 0.0f);
BMLoop **l_ptr_a = looptris[i++];
BMLoop **l_ptr_b = looptris[i++];
if (split_24 == 0) {
l_ptr_a[0] = l_v1;
l_ptr_a[1] = l_v2;
l_ptr_a[2] = l_v3;
l_ptr_b[0] = l_v1;
l_ptr_b[1] = l_v3;
l_ptr_b[2] = l_v4;
}
else {
l_ptr_a[0] = l_v1;
l_ptr_a[1] = l_v2;
l_ptr_a[2] = l_v4;
l_ptr_b[0] = l_v2;
l_ptr_b[1] = l_v3;
l_ptr_b[2] = l_v4;
}
}
else {
int j;
BMLoop *l_iter;
BMLoop *l_first;
BMLoop **l_arr;
float axis_mat[3][3];
float (*projverts)[2];
unsigned int (*tris)[3];
const int totfilltri = efa->len - 2;
if (UNLIKELY(pf_arena == NULL)) {
pf_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
pf_heap = BLI_heap_new_ex(BLI_POLYFILL_ALLOC_NGON_RESERVE);
pf_ehash = BLI_edgehash_new_ex(__func__, BLI_POLYFILL_ALLOC_NGON_RESERVE);
}
tris = BLI_memarena_alloc(pf_arena, sizeof(*tris) * totfilltri);
l_arr = BLI_memarena_alloc(pf_arena, sizeof(*l_arr) * efa->len);
projverts = BLI_memarena_alloc(pf_arena, sizeof(*projverts) * efa->len);
axis_dominant_v3_to_m3_negate(axis_mat, efa->no);
j = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
do {
l_arr[j] = l_iter;
mul_v2_m3v3(projverts[j], axis_mat, l_iter->v->co);
j++;
} while ((l_iter = l_iter->next) != l_first);
BLI_polyfill_calc_arena((const float (*)[2])projverts, efa->len, 1, tris, pf_arena);
BLI_polyfill_beautify((const float (*)[2])projverts, efa->len, tris, pf_arena, pf_heap, pf_ehash);
for (j = 0; j < totfilltri; j++) {
BMLoop **l_ptr = looptris[i++];
unsigned int *tri = tris[j];
l_ptr[0] = l_arr[tri[0]];
l_ptr[1] = l_arr[tri[1]];
l_ptr[2] = l_arr[tri[2]];
}
BLI_memarena_clear(pf_arena);
}
}
if (pf_arena) {
BLI_memarena_free(pf_arena);
BLI_heap_free(pf_heap, NULL);
BLI_edgehash_free(pf_ehash, NULL);
}
*r_looptris_tot = i;
BLI_assert(i <= looptris_tot);
}

View File

@ -33,6 +33,7 @@ struct Heap;
#include "BLI_compiler_attrs.h"
void BM_mesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot);
void BM_mesh_calc_tessellation_beauty(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot);
void BM_face_calc_tessellation(
const BMFace *f, const bool use_fixed_quad,

View File

@ -81,6 +81,7 @@ extern "C" {
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mask.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_mball.h"
@ -1262,7 +1263,18 @@ void DepsgraphNodeBuilder::build_mask(Mask *mask)
{
ID *mask_id = &mask->id;
add_id_node(mask_id);
/* F-Curve based animation/ */
build_animdata(mask_id);
/* Animation based on mask's shapes. */
add_operation_node(mask_id,
DEG_NODE_TYPE_ANIMATION,
function_bind(BKE_mask_eval_animation, _1, mask),
DEG_OPCODE_MASK_ANIMATION);
/* Final mask evaluation. */
add_operation_node(mask_id,
DEG_NODE_TYPE_PARAMETERS,
function_bind(BKE_mask_eval_update, _1, mask),
DEG_OPCODE_MASK_EVAL);
}
void DepsgraphNodeBuilder::build_movieclip(MovieClip *clip)

View File

@ -706,8 +706,12 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id,
depends_on_camera = true;
}
if (data->depth_ob) {
ComponentKey depth_key(&data->depth_ob->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(depth_key, constraint_op_key, cti->name);
ComponentKey depth_transform_key(&data->depth_ob->id,
DEG_NODE_TYPE_TRANSFORM);
ComponentKey depth_geometry_key(&data->depth_ob->id,
DEG_NODE_TYPE_GEOMETRY);
add_relation(depth_transform_key, constraint_op_key, cti->name);
add_relation(depth_geometry_key, constraint_op_key, cti->name);
}
}
else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
@ -1943,8 +1947,18 @@ void DepsgraphRelationBuilder::build_cachefile(CacheFile *cache_file) {
void DepsgraphRelationBuilder::build_mask(Mask *mask)
{
/* Animation. */
build_animdata(&mask->id);
ID *mask_id = &mask->id;
/* F-Curve animation. */
build_animdata(mask_id);
/* Own mask animation. */
OperationKey mask_animation_key(mask_id,
DEG_NODE_TYPE_ANIMATION,
DEG_OPCODE_MASK_ANIMATION);
TimeSourceKey time_src_key;
add_relation(time_src_key, mask_animation_key, "TimeSrc -> Mask Animation");
/* Final mask evaluation. */
ComponentKey parameters_key(mask_id, DEG_NODE_TYPE_PARAMETERS);
add_relation(mask_animation_key, parameters_key, "Mask Animation -> Mask Eval");
}
void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)

View File

@ -133,6 +133,9 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
STRINGIFY_OPCODE(PARTICLE_SYSTEM_EVAL);
STRINGIFY_OPCODE(PARTICLE_SETTINGS_EVAL);
STRINGIFY_OPCODE(PARTICLE_SETTINGS_RECALC_CLEAR);
/* Masks. */
STRINGIFY_OPCODE(MASK_ANIMATION);
STRINGIFY_OPCODE(MASK_EVAL);
/* Collections. */
STRINGIFY_OPCODE(SCENE_LAYER_INIT);
STRINGIFY_OPCODE(SCENE_LAYER_EVAL);

View File

@ -227,6 +227,10 @@ typedef enum eDepsOperation_Code {
DEG_OPCODE_MATERIAL_UPDATE,
DEG_OPCODE_WORLD_UPDATE,
/* Masks ------------------------------------------- */
DEG_OPCODE_MASK_ANIMATION,
DEG_OPCODE_MASK_EVAL,
DEG_NUM_OPCODES,
} eDepsOperation_Code;

View File

@ -1648,6 +1648,10 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
coll_search, NULL, NULL);
but->free_search_arg = true;
}
else if (but->type == UI_BTYPE_SEARCH_MENU) {
/* In case we fail to find proper searchprop, so other code might have already set but->type to search menu... */
but->type = UI_BTYPE_LABEL;
}
}
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)

View File

@ -253,7 +253,7 @@ void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me)
{
/* could be ldata or pdata */
CustomData *ldata = GET_CD_DATA(me, ldata);
const int layernum = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
const int layernum = CustomData_get_active_layer(ldata, CD_MLOOPUV);
ED_mesh_uv_loop_reset_ex(me, layernum);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);

View File

@ -222,7 +222,7 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I
if (!CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV);
/* make UVs all nice 0-1 */
ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer_index(&em->bm->ldata, CD_MLOOPUV));
ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV));
update = true;
}

View File

@ -513,6 +513,11 @@ static int startffmpeg(struct anim *anim)
avformat_close_input(&pFormatCtx);
return -1;
}
if (pCodecCtx->pix_fmt == AV_PIX_FMT_NONE) {
avcodec_close(anim->pCodecCtx);
avformat_close_input(&pFormatCtx);
return -1;
}
frame_rate = av_get_r_frame_rate_compat(pFormatCtx->streams[videoStream]);
if (pFormatCtx->streams[videoStream]->nb_frames != 0) {

View File

@ -228,7 +228,7 @@ static DerivedMesh *applyModifier_bmesh(
looptris = MEM_mallocN(sizeof(*looptris) * looptris_tot, __func__);
BM_mesh_calc_tessellation(bm, looptris, &tottri);
BM_mesh_calc_tessellation_beauty(bm, looptris, &tottri);
/* postpone this until after tessellating
* so we can use the original normals before the vertex are moved */