Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Hamalainen <blender@miikah.org>2011-06-16 16:00:03 +0400
committerMiika Hamalainen <blender@miikah.org>2011-06-16 16:00:03 +0400
commitb937a4f5b6adc6bc0dca62cb5c87db08c873cfba (patch)
treef489aca8e10e2a686fc1d1397397f99e1e1f2077 /source/blender/blenkernel
parent3de22dec26606c2c526f7193db038fa5125f9b03 (diff)
parentf227c4a064d96909243b4a60a7f6c544f521817a (diff)
Merge with trunk r37546
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_action.h2
-rw-r--r--source/blender/blenkernel/BKE_blender.h3
-rw-r--r--source/blender/blenkernel/BKE_brush.h4
-rw-r--r--source/blender/blenkernel/BKE_deform.h4
-rw-r--r--source/blender/blenkernel/BKE_depsgraph.h19
-rw-r--r--source/blender/blenkernel/BKE_displist.h5
-rw-r--r--source/blender/blenkernel/BKE_global.h1
-rw-r--r--source/blender/blenkernel/BKE_multires.h1
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/BKE_sequencer.h2
-rw-r--r--source/blender/blenkernel/BKE_texture.h2
-rw-r--r--source/blender/blenkernel/CMakeLists.txt18
-rw-r--r--source/blender/blenkernel/SConscript1
-rw-r--r--source/blender/blenkernel/depsgraph_private.h3
-rw-r--r--source/blender/blenkernel/intern/action.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c11
-rw-r--r--source/blender/blenkernel/intern/armature.c8
-rw-r--r--source/blender/blenkernel/intern/blender.c24
-rw-r--r--source/blender/blenkernel/intern/brush.c46
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c33
-rw-r--r--source/blender/blenkernel/intern/curve.c2
-rw-r--r--source/blender/blenkernel/intern/customdata.c2
-rw-r--r--source/blender/blenkernel/intern/deform.c4
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c17
-rw-r--r--source/blender/blenkernel/intern/displist.c496
-rw-r--r--source/blender/blenkernel/intern/image.c6
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/multires.c62
-rw-r--r--source/blender/blenkernel/intern/node.c11
-rw-r--r--source/blender/blenkernel/intern/object.c96
-rw-r--r--source/blender/blenkernel/intern/particle.c6
-rw-r--r--source/blender/blenkernel/intern/particle_system.c114
-rw-r--r--source/blender/blenkernel/intern/sca.c1
-rw-r--r--source/blender/blenkernel/intern/scene.c4
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c11
-rw-r--r--source/blender/blenkernel/intern/sequencer.c22
-rw-r--r--source/blender/blenkernel/intern/text.c19
-rw-r--r--source/blender/blenkernel/intern/texture.c22
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c122
40 files changed, 436 insertions, 776 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 698f0f0fecf..7d3de68c005 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -216,7 +216,7 @@ void pose_remove_group(struct Object *ob);
/* Assorted Evaluation ----------------- */
/* Used for the Action Constraint */
-void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe);
+void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe);
/* for proxy */
void copy_pose_result(struct bPose *to, struct bPose *from);
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 7e9f531162b..07f0885372a 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
/* these lines are grep'd, watch out for our not-so-awesome regex
* and keep comment above the defines.
- * Use STRINGIFY() rather then defining with quotes */
+ * Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 257
#define BLENDER_SUBVERSION 1
@@ -89,6 +89,7 @@ extern int BKE_undo_valid(const char *name);
extern void BKE_reset_undo(void);
extern char *BKE_undo_menu_string(void);
extern void BKE_undo_number(struct bContext *C, int nr);
+extern char *BKE_undo_get_name(int nr, int *active);
extern void BKE_undo_save_quit(void);
extern struct Main *BKE_undo_get_main(struct Scene **scene);
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index ad736cd07bf..ebb9714cd1b 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -71,7 +71,7 @@ float brush_curve_strength(struct Brush *br, float p, const float len); /* used
/* sampling */
void brush_sample_tex(struct Brush *brush, float *xy, float *rgba, const int thread);
void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
- struct ImBuf **imbuf);
+ struct ImBuf **imbuf, int use_color_correction);
/* painting */
struct BrushPainter;
@@ -82,7 +82,7 @@ BrushPainter *brush_painter_new(struct Brush *brush);
void brush_painter_require_imbuf(BrushPainter *painter, short flt,
short texonly, int size);
int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos,
- double time, float pressure, void *user);
+ double time, float pressure, void *user, int use_color_correction);
void brush_painter_break_stroke(BrushPainter *painter);
void brush_painter_free(BrushPainter *painter);
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index a9ac201beda..64cea929573 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -59,9 +59,9 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index
void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert);
void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify);
-void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int *flip_map, int use_verify);
+void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, int use_verify);
void defvert_remap (struct MDeformVert *dvert, int *map);
-void defvert_flip(struct MDeformVert *dvert, int *flip_map);
+void defvert_flip(struct MDeformVert *dvert, const int *flip_map);
void defvert_normalize(struct MDeformVert *dvert);
/* utility function, note that 32 chars is the maximum string length since its only
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h
index 14251fb1762..f36073ba841 100644
--- a/source/blender/blenkernel/BKE_depsgraph.h
+++ b/source/blender/blenkernel/BKE_depsgraph.h
@@ -51,22 +51,23 @@ struct GHash;
/* **** DAG relation types *** */
/* scene link to object */
-#define DAG_RL_SCENE 1
+#define DAG_RL_SCENE (1<<0)
/* object link to data */
-#define DAG_RL_DATA 2
+#define DAG_RL_DATA (1<<1)
/* object changes object (parent, track, constraints) */
-#define DAG_RL_OB_OB 4
+#define DAG_RL_OB_OB (1<<2)
/* object changes obdata (hooks, constraints) */
-#define DAG_RL_OB_DATA 8
+#define DAG_RL_OB_DATA (1<<3)
/* data changes object (vertex parent) */
-#define DAG_RL_DATA_OB 16
+#define DAG_RL_DATA_OB (1<<4)
/* data changes data (deformers) */
-#define DAG_RL_DATA_DATA 32
+#define DAG_RL_DATA_DATA (1<<5)
-#define DAG_NO_RELATION 64
-#define DAG_RL_ALL 63
-#define DAG_RL_ALL_BUT_DATA 61
+#define DAG_NO_RELATION (1<<6)
+
+#define DAG_RL_ALL_BUT_DATA (DAG_RL_SCENE|DAG_RL_OB_OB|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_DATA_DATA)
+#define DAG_RL_ALL (DAG_RL_ALL_BUT_DATA|DAG_RL_DATA)
typedef void (*graph_action_func)(void * ob, void **data);
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 68745975dae..b00db53a199 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -97,15 +97,10 @@ extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object
extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
extern void makeDispListMBall(struct Scene *scene, struct Object *ob);
extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
-extern void shadeDispList(struct Scene *scene, struct Base *base);
-extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me);
int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
-void reshadeall_displist(struct Scene *scene);
void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal);
-void fastshade_free_render(void);
-
float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot);
/* add Orco layer to the displist object which has got derived mesh and return orco */
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 0360acbea32..d21b0428d76 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -145,6 +145,7 @@ typedef struct Global {
#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) /* deprecated */
#define G_FILE_RECOVER (1 << 23)
#define G_FILE_RELATIVE_REMAP (1 << 24)
+#define G_FILE_HISTORY (1 << 25)
/* G.windowstate */
#define G_WINDOWSTATE_USERDEF 0
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index ea34ff4aa07..ba23b2d79c0 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -91,6 +91,7 @@ void multires_topology_changed(struct Scene *scene, struct Object *ob);
void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v);
void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side, const float x, const float y, float *u, float *v);
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
+int mdisp_rot_face_to_quad_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
void mdisp_apply_weight(const int S, const int corners, int x, int y, const int face_side, float crn_weight[4][2], float *u_r, float *v_r);
void mdisp_flip_disp(const int S, const int corners, const float axis_x[2], const float axis_y[2], float disp[3]);
void mdisp_join_tris(struct MDisps *dst, struct MDisps *tri1, struct MDisps *tri2);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 4dfc53e1734..feeab98ad78 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -300,6 +300,8 @@ void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, in
void psys_check_boid_data(struct ParticleSystem *psys);
+void psys_get_birth_coordinates(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra);
+
void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* ----------- functions needed only inside particlesystem ------------ */
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 94c474c668f..bedd58876bc 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -279,7 +279,7 @@ int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene);
int seqbase_isolated_sel_check(struct ListBase *seqbase);
void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage, int keep_file_handles);
struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence * seq, int dupe_flag);
-int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b);
+int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
void seq_update_sound(struct Scene* scene, struct Sequence *seq);
void seq_update_muting(struct Scene* scene, struct Editing *ed);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index c8fa7a5e81f..9fb93f60fd5 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -103,6 +103,8 @@ void set_current_material_texture(struct Material *ma, struct Tex *tex);
void set_current_lamp_texture(struct Lamp *la, struct Tex *tex);
void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex);
+int has_current_material_texture(struct Material *ma);
+
struct TexMapping *add_mapping(void);
void init_mapping(struct TexMapping *texmap);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index c7e4f20d7ad..8b6bca3805e 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -44,6 +44,7 @@ set(INC
../editors/include
../render/extern/include
../../../intern/audaspace/intern
+ ../../../intern/ffmpeg
../../../intern/bsp/extern ../blenfont
../../../intern/decimation/extern
../../../intern/elbeem/extern
@@ -54,6 +55,9 @@ set(INC
../../../intern/smoke/extern
../../../intern/mikktspace
../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h
+)
+
+set(INC_SYS
${GLEW_INCLUDE_PATH}
${ZLIB_INCLUDE_DIRS}
)
@@ -269,17 +273,19 @@ if(WITH_IMAGE_HDR)
endif()
if(WITH_CODEC_QUICKTIME)
- list(APPEND INC ../quicktime ${QUICKTIME_INC})
+ list(APPEND INC ../quicktime)
+ list(APPEND INC_SYS ${QUICKTIME_INC})
add_definitions(-DWITH_QUICKTIME)
endif()
if(WITH_CODEC_FFMPEG)
- list(APPEND INC ${FFMPEG_INC})
+ list(APPEND INC_SYS ${FFMPEG_INC})
add_definitions(-DWITH_FFMPEG)
endif()
if(WITH_PYTHON)
- list(APPEND INC ../python ${PYTHON_INCLUDE_DIRS})
+ list(APPEND INC ../python)
+ list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS})
add_definitions(-DWITH_PYTHON)
if(WITH_PYTHON_SECURITY)
@@ -300,12 +306,12 @@ if(WITH_JACK)
endif()
if(WITH_LZO)
- list(APPEND INC ../../../extern/lzo/minilzo)
+ list(APPEND INC_SYS ../../../extern/lzo/minilzo)
add_definitions(-DWITH_LZO)
endif()
if(WITH_LZMA)
- list(APPEND INC ../../../extern/lzma)
+ list(APPEND INC_SYS ../../../extern/lzma)
add_definitions(-DWITH_LZMA)
endif()
@@ -313,4 +319,4 @@ if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif()
-blender_add_lib(bf_blenkernel "${SRC}" "${INC}")
+blender_add_lib(bf_blenkernel "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index ea19b51c044..b5f845acacb 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -14,6 +14,7 @@ incs += ' ../gpu #/extern/glew/include'
incs += ' #/intern/smoke/extern'
incs += ' #/intern/mikktspace'
incs += ' #/intern/audaspace/intern'
+incs += ' #/intern/ffmpeg'
incs += ' ' + env['BF_OPENGL_INC']
incs += ' ' + env['BF_ZLIB_INC']
diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h
index 1fed115893c..ef4f320602b 100644
--- a/source/blender/blenkernel/depsgraph_private.h
+++ b/source/blender/blenkernel/depsgraph_private.h
@@ -69,8 +69,9 @@ typedef struct DagNode
void * ob;
void * first_ancestor;
int ancestor_count;
- unsigned int lay; // accumulated layers of its relations + itself
+ unsigned int lay; // accumulated layers of its relations + itself
unsigned int scelay; // layers due to being in scene
+ unsigned int customdata_mask; // customdata mask
int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing
int BFS_dist; // BFS distance
int DFS_dist; // DFS distance
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 77f56058a4f..f7086c81756 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1128,7 +1128,7 @@ void copy_pose_result(bPose *to, bPose *from)
/* For the calculation of the effects of an Action at the given frame on an object
* This is currently only used for the Action Constraint
*/
-void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
+void what_does_obaction (Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
{
bActionGroup *agrp= action_groups_find_named(act, groupname);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 5198172c205..fdc102bf779 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1043,6 +1043,9 @@ static short animsys_remap_path (AnimMapper *UNUSED(remap), char *path, char **d
}
+/* less then 1.0 evaluates to false, use epsilon to avoid float error */
+#define ANIMSYS_FLOAT_AS_BOOL(value) ((value) > ((1.0f-FLT_EPSILON)))
+
/* Write the given value to a setting using RNA, and return success */
static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
{
@@ -1074,9 +1077,9 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
{
case PROP_BOOLEAN:
if (array_len)
- RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
+ RNA_property_boolean_set_index(&new_ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
else
- RNA_property_boolean_set(&new_ptr, prop, (int)value);
+ RNA_property_boolean_set(&new_ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
break;
case PROP_INT:
if (array_len)
@@ -1867,9 +1870,9 @@ void nladata_flush_channels (ListBase *channels)
{
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
- RNA_property_boolean_set_index(ptr, prop, array_index, (int)value);
+ RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
else
- RNA_property_boolean_set(ptr, prop, (int)value);
+ RNA_property_boolean_set(ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
break;
case PROP_INT:
if (RNA_property_array_length(ptr, prop))
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index fd25ebe266f..0b31e51d62e 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1343,8 +1343,12 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
cross_v3_v3v3(axis,target,nor);
/* was 0.0000000000001, caused bug [#23954], smaller values give unstable
- * roll when toggling editmode */
- if (dot_v3v3(axis,axis) > 0.00001f) {
+ * roll when toggling editmode.
+ *
+ * was 0.00001, causes bug [#27675], with 0.00000495,
+ * so a value inbetween these is needed.
+ */
+ if (dot_v3v3(axis,axis) > 0.000001f) {
/* if nor is *not* a multiple of target ... */
normalize_v3(axis);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 2fce1175fe1..0f545ad3ff9 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -154,7 +154,6 @@ static void clear_global(void)
{
// extern short winqueue_break; /* screen.c */
- fastshade_free_render(); /* lamps hang otherwise */
free_main(G.main); /* free all lib data */
// free_vertexpaint();
@@ -180,7 +179,6 @@ static void clean_paths(Main *main)
BLI_bpathIterator_free(bpi);
for(scene= main->scene.first; scene; scene= scene->id.next) {
- BLI_clean(scene->r.backbuf);
BLI_clean(scene->r.pic);
}
}
@@ -523,7 +521,8 @@ void BKE_write_undo(bContext *C, const char *name)
static int counter= 0;
char filepath[FILE_MAXDIR+FILE_MAXFILE];
char numstr[32];
-
+ int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
+
/* calculate current filepath */
counter++;
counter= counter % U.undosteps;
@@ -531,7 +530,7 @@ void BKE_write_undo(bContext *C, const char *name)
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_make_file_string("/", filepath, btempdir, numstr);
- success= BLO_write_file(CTX_data_main(C), filepath, G.fileflags, NULL, NULL);
+ success= BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
}
@@ -619,7 +618,7 @@ void BKE_reset_undo(void)
/* based on index nr it does a restore */
void BKE_undo_number(bContext *C, int nr)
{
- curundo= BLI_findlink(&undobase, nr - 1);
+ curundo= BLI_findlink(&undobase, nr);
BKE_undo_step(C, 0);
}
@@ -645,6 +644,21 @@ int BKE_undo_valid(const char *name)
return undobase.last != undobase.first;
}
+/* get name of undo item, return null if no item with this index */
+/* if active pointer, set it to 1 if true */
+char *BKE_undo_get_name(int nr, int *active)
+{
+ UndoElem *uel= BLI_findlink(&undobase, nr);
+
+ if(active) *active= 0;
+
+ if(uel) {
+ if(active && uel==curundo)
+ *active= 1;
+ return uel->name;
+ }
+ return NULL;
+}
char *BKE_undo_menu_string(void)
{
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 98c540f53b7..a4ceb62ab55 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -521,7 +521,7 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba, const int thread)
}
-void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf)
+void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction)
{
ImBuf *ibuf;
float xy[2], dist, rgba[4], *dstf;
@@ -529,7 +529,8 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
const int radius= brush_size(brush);
char *dst, crgb[3];
const float alpha= brush_alpha(brush);
-
+ float brush_rgb[3];
+
imbflag= (flt)? IB_rectfloat: IB_rect;
xoff = -bufsize/2.0f + 0.5f;
yoff = -bufsize/2.0f + 0.5f;
@@ -541,6 +542,11 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag);
if (flt) {
+ copy_v3_v3(brush_rgb, brush->rgb);
+ if(use_color_correction){
+ srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
+ }
+
for (y=0; y < ibuf->y; y++) {
dstf = ibuf->rect_float + y*rowbytes;
@@ -551,7 +557,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
if (texfall == 0) {
dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
- VECCOPY(dstf, brush->rgb);
+ VECCOPY(dstf, brush_rgb);
dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius);
}
else if (texfall == 1) {
@@ -561,10 +567,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
brush_sample_tex(brush, xy, rgba, 0);
-
- dstf[0] = rgba[0]*brush->rgb[0];
- dstf[1] = rgba[1]*brush->rgb[1];
- dstf[2] = rgba[2]*brush->rgb[2];
+ mul_v3_v3v3(dstf, rgba, brush_rgb);
dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, dist, radius);
}
}
@@ -862,7 +865,7 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float
brush_painter_do_partial(painter, NULL, x1, y2, x2, ibuf->y, 0, 0, pos);
}
-static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
+static void brush_painter_refresh_cache(BrushPainter *painter, float *pos, int use_color_correction)
{
Brush *brush= painter->brush;
BrushPainterCache *cache= &painter->cache;
@@ -889,11 +892,11 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
size= (cache->size)? cache->size: diameter;
if (brush->flag & BRUSH_FIXED_TEX) {
- brush_imbuf_new(brush, flt, 3, size, &cache->maskibuf);
+ brush_imbuf_new(brush, flt, 3, size, &cache->maskibuf, use_color_correction);
brush_painter_fixed_tex_partial_update(painter, pos);
}
else
- brush_imbuf_new(brush, flt, 2, size, &cache->ibuf);
+ brush_imbuf_new(brush, flt, 2, size, &cache->ibuf, use_color_correction);
cache->lastsize= diameter;
cache->lastalpha= alpha;
@@ -952,7 +955,7 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
}
}
-int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user)
+int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user, int use_color_correction)
{
Brush *brush= painter->brush;
int totpaintops= 0;
@@ -970,7 +973,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_apply_pressure(painter, brush, pressure);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, pos);
+ brush_painter_refresh_cache(painter, pos, use_color_correction);
totpaintops += func(user, painter->cache.ibuf, pos, pos);
painter->lasttime= time;
@@ -1043,7 +1046,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_jitter_pos(brush, paintpos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction);
totpaintops +=
func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos);
@@ -1057,7 +1060,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_jitter_pos(brush, pos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction);
totpaintops += func(user, painter->cache.ibuf, pos, finalpos);
@@ -1085,7 +1088,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_jitter_pos(brush, pos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction);
totpaintops +=
func(user, painter->cache.ibuf, painter->lastmousepos, finalpos);
@@ -1251,6 +1254,19 @@ static short unified_settings(Brush *brush)
return 0;
}
+// XXX: be careful about setting size and unprojected radius
+// because they depend on one another
+// these functions do not set the other corresponding value
+// this can lead to odd behavior if size and unprojected
+// radius become inconsistent.
+// the biggest problem is that it isn't possible to change
+// unprojected radius because a view context is not
+// available. my ussual solution to this is to use the
+// ratio of change of the size to change the unprojected
+// radius. Not completely convinced that is correct.
+// In anycase, a better solution is needed to prevent
+// inconsistency.
+
static void set_unified_size(Brush *brush, int value)
{
Scene *sce;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index f49f1aea0b8..fa6a8239282 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -493,7 +493,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co,
// NOTE: casts to "float*" here are due to co being "const float*"
closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1);
- dist = len_v3v3(nearest_tmp, (float*)co);
+ dist = len_squared_v3v3(nearest_tmp, (float*)co);
if(dist < nearest->dist)
{
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index d3c14a9dd12..7be4744a224 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -424,7 +424,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
/* ------------ General Target Matrix Tools ---------- */
/* function that sets the given matrix based on given vertex group in mesh */
-static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4])
+static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4])
{
DerivedMesh *dm = NULL;
Mesh *me= ob->data;
@@ -449,16 +449,9 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substr
freeDM= 1;
}
else {
- /* when not in EditMode, use the 'final' derived mesh
- * - check if the custom data masks for derivedFinal mean that we can just use that
- * (this is more effficient + sufficient for most cases)
- */
- if (!(ob->lastDataMask & CD_MASK_MDEFORMVERT)) {
- dm = mesh_get_derived_final(scene, ob, CD_MASK_MDEFORMVERT);
- freeDM= 1;
- }
- else
- dm = (DerivedMesh *)ob->derivedFinal;
+ /* when not in EditMode, use the 'final' derived mesh, depsgraph
+ * ensures we build with CD_MDEFORMVERT layer */
+ dm = (DerivedMesh *)ob->derivedFinal;
}
/* only continue if there's a valid DerivedMesh */
@@ -587,7 +580,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float
/* generic function to get the appropriate matrix for most target cases */
/* The cases where the target can be object data have not been implemented */
-static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
+static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
{
/* Case OBJECT */
if (!strlen(substring)) {
@@ -604,7 +597,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *sub
* way as constraints can only really affect things on object/bone level.
*/
else if (ob->type == OB_MESH) {
- contarget_get_mesh_mat(scene, ob, substring, mat);
+ contarget_get_mesh_mat(ob, substring, mat);
constraint_mat_convertspace(ob, NULL, mat, from, to);
}
else if (ob->type == OB_LATTICE) {
@@ -684,10 +677,10 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
/* This function should be used for the get_target_matrix member of all
* constraints that are not picky about what happens to their target matrix.
*/
-static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
{
if (VALID_CONS_TARGET(ct))
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
else if (ct)
unit_m4(ct->matrix);
}
@@ -1159,7 +1152,7 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra
bKinematicConstraint *data= con->data;
if (VALID_CONS_TARGET(ct))
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
else if (ct) {
if (data->flag & CONSTRAINT_IK_AUTO) {
Object *ob= cob->ob;
@@ -2046,7 +2039,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT
/* firstly calculate the matrix the normal way, then let the py-function override
* this matrix if it needs to do so
*/
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
/* only execute target calculation if allowed */
#ifdef WITH_PYTHON
@@ -2165,7 +2158,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
unit_m4(ct->matrix);
/* get the transform matrix of the target */
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
/* determine where in transform range target is */
/* data->type is mapped as follows for backwards compatability:
@@ -2216,7 +2209,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
tchan->rotmode= pchan->rotmode;
/* evaluate action using workob (it will only set the PoseChannel in question) */
- what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t);
+ what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t);
/* convert animation to matrices for use here */
pchan_calc_mat(tchan);
@@ -2230,7 +2223,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
/* evaluate using workob */
// FIXME: we don't have any consistent standards on limiting effects on object...
- what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, NULL, t);
+ what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
object_to_mat4(&workob, ct->matrix);
}
else {
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index b104c6c9b30..704af73dd10 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1859,7 +1859,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
* do this by calculating the tilt angle difference, then apply
* the rotation gradually over the entire curve
*
- * note that the split is between last and second last, rather then first/last as youd expect.
+ * note that the split is between last and second last, rather than first/last as youd expect.
*
* real order is like this
* 0,1,2,3,4 --> 1,2,3,4,0
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index f5f069767eb..45faba8439c 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -540,7 +540,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
float face_u, face_v, crn_u, crn_v;
mdisp_apply_weight(S, dst_corners, x, y, st, crn_weight, &face_u, &face_v);
- crn = mdisp_rot_face_to_crn(src_corners, st, face_u, face_v, &crn_u, &crn_v);
+ crn = mdisp_rot_face_to_quad_crn(src_corners, st, face_u, face_v, &crn_u, &crn_v);
old_mdisps_bilinear((*out), &s->disps[crn*side*side], side, crn_u, crn_v);
mdisp_flip_disp(crn, dst_corners, axis_x, axis_y, *out);
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 0696653d2e4..11a0a5884ee 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -121,7 +121,7 @@ void defvert_sync (MDeformVert *dvert_r, const MDeformVert *dvert, int use_verif
}
/* be sure all flip_map values are valid */
-void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, int *flip_map, int use_verify)
+void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, const int *flip_map, int use_verify)
{
if(dvert->totweight && dvert_r->totweight) {
int i;
@@ -170,7 +170,7 @@ void defvert_normalize (MDeformVert *dvert)
}
}
-void defvert_flip (MDeformVert *dvert, int *flip_map)
+void defvert_flip (MDeformVert *dvert, const int *flip_map)
{
MDeformWeight *dw;
int i;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 472d7d77b80..c2800410657 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -372,6 +372,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
node2->first_ancestor = ob;
node2->ancestor_count += 1;
}
+
+ /* also build a custom data mask for dependencies that need certain layers */
+ node->customdata_mask= 0;
if (ob->type == OB_ARMATURE) {
if (ob->pose){
@@ -451,8 +454,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
case PARSKEL:
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent");
break;
- case PARVERT1: case PARVERT3: case PARBONE:
+ case PARVERT1: case PARVERT3:
dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent");
+ node2->customdata_mask |= CD_MASK_ORIGINDEX;
+ break;
+ case PARBONE:
+ dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent");
break;
default:
if(ob->parent->type==OB_LATTICE)
@@ -647,8 +654,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO))
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
else {
- if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0]))
+ if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) {
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
+ if (obt->type == OB_MESH)
+ node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+ }
else
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, cti->name);
}
@@ -722,6 +732,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
itA->node->color |= itA->type;
}
}
+
+ /* also flush custom data mask */
+ ((Object*)node->ob)->customdata_mask= node->customdata_mask;
}
}
/* now set relations equal, so that when only one parent changes, the correct recalcs are found */
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 9aa794aa97e..8f57490d057 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -65,9 +65,6 @@
#include "BKE_lattice.h"
#include "BKE_modifier.h"
-#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
-
#include "BLO_sys_types.h" // for intptr_t support
#include "ED_curve.h" /* for BKE_curve_nurbs */
@@ -286,499 +283,6 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i
return 1;
}
-/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */
-
-/* create default shade input... save cpu cycles with ugly global */
-/* XXXX bad code warning: local ShadeInput initialize... */
-static ShadeInput shi;
-static void init_fastshade_shadeinput(Render *re)
-{
- memset(&shi, 0, sizeof(ShadeInput));
- shi.lay= RE_GetScene(re)->lay;
- shi.view[2]= -1.0f;
- shi.passflag= SCE_PASS_COMBINED;
- shi.combinedflag= -1;
-}
-
-static Render *fastshade_get_render(Scene *UNUSED(scene))
-{
- // XXX 2.5: this crashes combined with previewrender
- // due to global R so disabled for now
-#if 0
- /* XXX ugly global still, but we can't do preview while rendering */
- if(G.rendering==0) {
-
- Render *re= RE_GetRender("_Shade View_");
- if(re==NULL) {
- re= RE_NewRender("_Shade View_");
-
- RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */
- }
- return re;
- }
-#endif
-
- return NULL;
-}
-
-/* called on file reading */
-void fastshade_free_render(void)
-{
- Render *re= RE_GetRender("_Shade View_");
-
- if(re) {
- RE_Database_Free(re);
- RE_FreeRender(re);
- }
-}
-
-
-static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma)
-{
- CustomDataLayer *layer;
- MTFace *mtface;
- int index, needuv= ma->texco & TEXCO_UV;
- char *vertcol;
-
- shi.totuv= 0;
- shi.totcol= 0;
-
- for(index=0; index<fdata->totlayer; index++) {
- layer= &fdata->layers[index];
-
- if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) {
- mtface= &((MTFace*)layer->data)[a];
-
- shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f;
- shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f;
- shi.uv[shi.totuv].uv[2]= 1.0f;
-
- shi.uv[shi.totuv].name= layer->name;
- shi.totuv++;
- }
- else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) {
- vertcol= (char*)&((MCol*)layer->data)[a*4 + j];
-
- shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f;
- shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f;
- shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f;
-
- shi.col[shi.totcol].name= layer->name;
- shi.totcol++;
- }
- }
-
- if(needuv && shi.totuv == 0)
- VECCOPY(shi.uv[0].uv, shi.lo);
-
- if(shi.totcol)
- VECCOPY(shi.vcol, shi.col[0].col);
-}
-
-static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2)
-{
- ShadeResult shr;
- int a;
-
- VECCOPY(shi.co, co);
- shi.vn[0]= -nor[0];
- shi.vn[1]= -nor[1];
- shi.vn[2]= -nor[2];
- VECCOPY(shi.vno, shi.vn);
- VECCOPY(shi.facenor, shi.vn);
-
- if(ma->texco) {
- VECCOPY(shi.lo, orco);
-
- if(ma->texco & TEXCO_GLOB) {
- VECCOPY(shi.gl, shi.lo);
- }
- if(ma->texco & TEXCO_WINDOW) {
- VECCOPY(shi.winco, shi.lo);
- }
- if(ma->texco & TEXCO_STICKY) {
- VECCOPY(shi.sticky, shi.lo);
- }
- if(ma->texco & TEXCO_OBJECT) {
- VECCOPY(shi.co, shi.lo);
- }
- if(ma->texco & TEXCO_NORM) {
- VECCOPY(shi.orn, shi.vn);
- }
- if(ma->texco & TEXCO_REFL) {
- float inp= 2.0f * (shi.vn[2]);
- shi.ref[0]= (inp*shi.vn[0]);
- shi.ref[1]= (inp*shi.vn[1]);
- shi.ref[2]= (-1.0f + inp*shi.vn[2]);
- }
- }
-
- shi.mat= ma; /* set each time... node shaders change it */
- RE_shade_external(NULL, &shi, &shr);
-
- a= 256.0f*(shr.combined[0]);
- col1[0]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[1]);
- col1[1]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[2]);
- col1[2]= CLAMPIS(a, 0, 255);
-
- if(col2) {
- shi.vn[0]= -shi.vn[0];
- shi.vn[1]= -shi.vn[1];
- shi.vn[2]= -shi.vn[2];
-
- shi.mat= ma; /* set each time... node shaders change it */
- RE_shade_external(NULL, &shi, &shr);
-
- a= 256.0f*(shr.combined[0]);
- col2[0]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[1]);
- col2[1]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[2]);
- col2[2]= CLAMPIS(a, 0, 255);
- }
-}
-
-static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3])
-{
- float tmat[4][4];
- float amb[3]= {0.0f, 0.0f, 0.0f};
- int a;
-
- /* initialize globals in render */
- RE_shade_external(re, NULL, NULL);
-
- /* initialize global here */
- init_fastshade_shadeinput(re);
-
- RE_DataBase_GetView(re, tmat);
- mul_m4_m4m4(mat, ob->obmat, tmat);
-
- invert_m4_m4(tmat, mat);
- copy_m3_m4(imat, tmat);
- if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0);
-
- if (need_orco_r) *need_orco_r= 0;
- for(a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a+1);
- if(ma) {
- init_render_material(ma, 0, amb);
-
- if(ma->texco & TEXCO_ORCO) {
- if (need_orco_r) *need_orco_r= 1;
- }
- }
- }
-}
-
-static void end_fastshade_for_ob(Object *ob)
-{
- int a;
-
- for(a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a+1);
- if(ma)
- end_render_material(ma);
- }
-}
-
-
-static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
-{
- Mesh *me= ob->data;
- DerivedMesh *dm;
- MVert *mvert;
- MFace *mface;
- unsigned int *col1, *col2;
- float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3];
- int a, i, need_orco, totface, totvert;
- CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL
- | CD_MASK_MTFACE | CD_MASK_NORMAL;
-
-
- init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
-
- if(need_orco)
- dataMask |= CD_MASK_ORCO;
-
- if (onlyForMesh)
- dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask);
- else
- dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask);
-
- mvert = dm->getVertArray(dm);
- mface = dm->getFaceArray(dm);
- nors = dm->getFaceDataArray(dm, CD_NORMAL);
- totvert = dm->getNumVerts(dm);
- totface = dm->getNumFaces(dm);
- orco= dm->getVertDataArray(dm, CD_ORCO);
-
- if (onlyForMesh) {
- col1 = *col1_r;
- col2 = NULL;
- } else {
- *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1");
-
- if (col2_r && (me->flag & ME_TWOSIDED))
- col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2");
- else
- col2 = NULL;
-
- if (col2_r) *col2_r = col2;
- }
-
- /* vertexnormals */
- vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp");
- for (a=0; a<totvert; a++) {
- MVert *mv = &mvert[a];
- float *vn= &vnors[a*3];
- float xn= mv->no[0];
- float yn= mv->no[1];
- float zn= mv->no[2];
-
- /* transpose ! */
- vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
- vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
- vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
- normalize_v3(vn);
- }
-
- for (i=0; i<totface; i++) {
- MFace *mf= &mface[i];
- Material *ma= give_current_material(ob, mf->mat_nr+1);
- int j, vidx[4], nverts= mf->v4?4:3;
- unsigned char *col1base= (unsigned char*) &col1[i*4];
- unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
- float nor[3], n1[3];
-
- if(ma==NULL) ma= &defmaterial;
-
- vidx[0]= mf->v1;
- vidx[1]= mf->v2;
- vidx[2]= mf->v3;
- vidx[3]= mf->v4;
-
- if (nors) {
- VECCOPY(nor, &nors[i*3]);
- } else {
- if (mf->v4)
- normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
- else
- normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
- }
-
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- normalize_v3(n1);
-
- for (j=0; j<nverts; j++) {
- MVert *mv= &mvert[vidx[j]];
- char *col1= (char*)&col1base[j*4];
- char *col2= (char*)(col2base?&col2base[j*4]:NULL);
- float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
-
- mul_v3_m4v3(vec, mat, mv->co);
-
- mul_v3_v3fl(vec, vn, 0.001f);
-
- fastshade_customdata(&dm->faceData, i, j, ma);
- fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2);
- }
- }
- MEM_freeN(vnors);
-
- dm->release(dm);
-
- end_fastshade_for_ob(ob);
-}
-
-void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me)
-{
- Render *re= fastshade_get_render(scene);
- int a;
- char *cp;
- unsigned int *mcol= (unsigned int*)me->mcol;
-
- if(re) {
- mesh_create_shadedColors(re, ob, 1, &mcol, NULL);
- me->mcol= (MCol*)mcol;
-
- /* swap bytes */
- for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) {
- SWAP(char, cp[0], cp[3]);
- SWAP(char, cp[1], cp[2]);
- }
- }
-}
-
-/* has base pointer, to check for layer */
-/* called from drawobject.c */
-void shadeDispList(Scene *scene, Base *base)
-{
- Object *ob= base->object;
- DispList *dl, *dlob;
- Material *ma = NULL;
- Render *re;
- float imat[3][3], mat[4][4], vec[3];
- float *fp, *nor, n1[3];
- unsigned int *col1;
- int a, need_orco;
-
- re= fastshade_get_render(scene);
- if(re==NULL)
- return;
-
- dl = find_displist(&ob->disp, DL_VERTCOL);
- if (dl) {
- BLI_remlink(&ob->disp, dl);
- free_disp_elem(dl);
- }
-
- if(ob->type==OB_MESH) {
- dl= MEM_callocN(sizeof(DispList), "displistshade");
- dl->type= DL_VERTCOL;
-
- mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2);
-
- /* add dl to ob->disp after mesh_create_shadedColors, because it
- might indirectly free ob->disp */
- BLI_addtail(&ob->disp, dl);
- }
- else {
-
- init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
-
- if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-
- /* now we need the normals */
- dl= ob->disp.first;
-
- while(dl) {
- dlob= MEM_callocN(sizeof(DispList), "displistshade");
- BLI_addtail(&ob->disp, dlob);
- dlob->type= DL_VERTCOL;
- dlob->parts= dl->parts;
- dlob->nr= dl->nr;
-
- if(dl->type==DL_INDEX3) {
- col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
- }
- else {
- col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1");
- }
-
-
- ma= give_current_material(ob, dl->col+1);
- if(ma==NULL) ma= &defmaterial;
-
- if(dl->type==DL_INDEX3) {
- if(dl->nors) {
- /* there's just one normal */
- n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2];
- n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2];
- n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2];
- normalize_v3(n1);
-
- fp= dl->verts;
-
- a= dl->nr;
- while(a--) {
- mul_v3_m4v3(vec, mat, fp);
-
- fastshade(vec, n1, fp, ma, (char *)col1, NULL);
-
- fp+= 3; col1++;
- }
- }
- }
- else if(dl->type==DL_SURF) {
- if(dl->nors) {
- a= dl->nr*dl->parts;
- fp= dl->verts;
- nor= dl->nors;
-
- while(a--) {
- mul_v3_m4v3(vec, mat, fp);
-
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- normalize_v3(n1);
-
- fastshade(vec, n1, fp, ma, (char *)col1, NULL);
-
- fp+= 3; nor+= 3; col1++;
- }
- }
- }
- dl= dl->next;
- }
- }
- else if(ob->type==OB_MBALL) {
- /* there are normals already */
- dl= ob->disp.first;
-
- while(dl) {
-
- if(dl->type==DL_INDEX4) {
- if(dl->nors) {
- if(dl->col1) MEM_freeN(dl->col1);
- col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
-
- ma= give_current_material(ob, dl->col+1);
- if(ma==NULL) ma= &defmaterial;
-
- fp= dl->verts;
- nor= dl->nors;
-
- a= dl->nr;
- while(a--) {
- mul_v3_m4v3(vec, mat, fp);
-
- /* transpose ! */
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- normalize_v3(n1);
-
- fastshade(vec, n1, fp, ma, (char *)col1, NULL);
-
- fp+= 3; col1++; nor+= 3;
- }
- }
- }
- dl= dl->next;
- }
- }
-
- end_fastshade_for_ob(ob);
- }
-}
-
-/* frees render and shade part of displists */
-/* note: dont do a shade again, until a redraw happens */
-void reshadeall_displist(Scene *scene)
-{
- Base *base;
- Object *ob;
-
- fastshade_free_render();
-
- for(base= scene->base.first; base; base= base->next) {
- ob= base->object;
-
- if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
- freedisplist(&ob->disp);
-
- if(base->lay & scene->lay) {
- /* Metaballs have standard displist at the Object */
- if(ob->type==OB_MBALL) shadeDispList(scene, base);
- }
- }
-}
-
/* ****************** make displists ********************* */
static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender)
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 22d19c5484f..c48497c45a1 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -381,9 +381,7 @@ Image *BKE_add_image_file(const char *name)
ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE);
BLI_strncpy(ima->name, name, sizeof(ima->name));
- /* do a wild guess! */
- if(BLI_testextensie(name, ".avi") || BLI_testextensie(name, ".mov")
- || BLI_testextensie(name, ".mpg") || BLI_testextensie(name, ".mp4"))
+ if(BLI_testextensie_array(name, imb_ext_movie))
ima->source= IMA_SRC_MOVIE;
return ima;
@@ -1031,7 +1029,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
pad= BLF_width_max(mono);
- /* use 'h_fixed' rather then 'h', aligns better */
+ /* use 'h_fixed' rather than 'h', aligns better */
h_fixed= BLF_height_max(mono);
y_ofs = -BLF_descender(mono);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index f0ac7040deb..094214858f9 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -607,7 +607,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
if(cd->no_rot_axis) { /* set by caller */
- /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then
+ /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than
* changing the axis before calculating the tilt but serves much the same purpose */
float dir_flat[3]={0,0,0}, q[4];
copy_v3_v3(dir_flat, dir);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 637f5da45af..d833c184274 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -1020,7 +1020,7 @@ static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, in
static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
{
- int newlvl = log(sqrt(mdisp->totdisp)-1)/log(2);
+ int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2;
int oldlvl = newlvl+1;
int oldside = multires_side_tot[oldlvl];
int newside = multires_side_tot[newlvl];
@@ -1756,7 +1756,7 @@ void multires_topology_changed(Scene *scene, Object *ob)
int nvert= me->mface[i].v4 ? 4 : 3;
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
- if(!mdisp->totdisp) {
+ if(!mdisp->totdisp || !mdisp->disps) {
if(grid) {
mdisp->totdisp= nvert*grid;
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
@@ -1997,6 +1997,7 @@ void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side,
}
}
+/* Find per-corner coordinate with given per-face UV coord */
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
{
const float offset = face_side*0.5f - 0.5f;
@@ -2022,6 +2023,61 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
*y = v - offset;
}
} else {
+ int grid_size = offset;
+ float w = (face_side - 1) - u - v;
+ float W1, W2;
+
+ if (u >= v && u >= w) {S = 0; W1= w; W2= v;}
+ else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w;}
+ else {S = 2; W1 = v; W2 = u;}
+
+ W1 /= (face_side-1);
+ W2 /= (face_side-1);
+
+ *x = (1-(2*W1)/(1-W2)) * grid_size;
+ *y = (1-(2*W2)/(1-W1)) * grid_size;
+ }
+
+ return S;
+}
+
+/* Find per-corner coordinate with given per-face UV coord
+ Practically as the previous funciton but it assumes a bit different coordinate system for triangles
+ which is optimized for MDISP layer interpolation:
+
+ v
+ ^
+ | /|
+ | / |
+ | / |
+ |/______|___> u
+
+ */
+int mdisp_rot_face_to_quad_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
+{
+ const float offset = face_side*0.5f - 0.5f;
+ int S = 0;
+
+ if (corners == 4) {
+ if(u <= offset && v <= offset) S = 0;
+ else if(u > offset && v <= offset) S = 1;
+ else if(u > offset && v > offset) S = 2;
+ else if(u <= offset && v >= offset) S = 3;
+
+ if(S == 0) {
+ *y = offset - u;
+ *x = offset - v;
+ } else if(S == 1) {
+ *x = u - offset;
+ *y = offset - v;
+ } else if(S == 2) {
+ *y = u - offset;
+ *x = v - offset;
+ } else if(S == 3) {
+ *x= offset - u;
+ *y = v - offset;
+ }
+ } else {
float crn[3][4][2];
float p[2] = {u, v};
@@ -2148,7 +2204,7 @@ void mdisp_join_tris(MDisps *dst, MDisps *tri1, MDisps *tri2)
face_v = st - 1 - face_v;
} else src = tri1;
- crn = mdisp_rot_face_to_crn(3, st, face_u, face_v, &crn_u, &crn_v);
+ crn = mdisp_rot_face_to_quad_crn(3, st, face_u, face_v, &crn_u, &crn_v);
old_mdisps_bilinear((*out), &src->disps[crn*side*side], side, crn_u, crn_v);
(*out)[0] = 0;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index ba2434bba23..3a8a2ae9c09 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -350,7 +350,7 @@ static bNodeType ntype_group;
/* groups display their internal tree name as label */
static const char *group_label(bNode *node)
{
- return node->id->name+2;
+ return (node->id)? node->id->name+2: "Missing Datablock";
}
void register_node_type_group(ListBase *lb)
@@ -2072,11 +2072,12 @@ static int set_stack_indexes_group(bNode *node, int index)
bNodeTree *ngroup= (bNodeTree*)node->id;
bNodeSocket *sock;
- if((ngroup->init & NTREE_TYPE_INIT)==0)
+ if(ngroup && (ngroup->init & NTREE_TYPE_INIT)==0)
ntreeInitTypes(ngroup);
node->stack_index = index;
- index += ntree_begin_exec_tree(ngroup);
+ if(ngroup)
+ index += ntree_begin_exec_tree(ngroup);
for (sock=node->inputs.first; sock; sock=sock->next) {
if (sock->link && sock->link->fromsock) {
@@ -2199,7 +2200,7 @@ static void composit_begin_exec(bNodeTree *ntree, bNodeStack *stack)
if(node->type==CMP_NODE_CURVE_RGB)
curvemapping_premultiply(node->storage, 0);
}
- if(node->type==NODE_GROUP)
+ if(node->type==NODE_GROUP && node->id)
composit_begin_exec((bNodeTree *)node->id, stack + node->stack_index);
}
@@ -2225,7 +2226,7 @@ static void composit_end_exec(bNodeTree *ntree, bNodeStack *stack)
if(node->type==CMP_NODE_CURVE_RGB)
curvemapping_premultiply(node->storage, 1);
- if(node->type==NODE_GROUP)
+ if(node->type==NODE_GROUP && node->id)
composit_end_exec((bNodeTree *)node->id, stack + node->stack_index);
node->need_exec= 0;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 3523d1812a0..dff62b05bd3 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1764,7 +1764,7 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
object_apply_mat4(ob, rmat, use_compat, FALSE);
- /* same as below, use rmat rather then mat */
+ /* same as below, use rmat rather than mat */
mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat);
object_mat3_to_rot(ob, rot, use_compat);
}
@@ -2387,24 +2387,42 @@ void object_set_dimensions(Object *ob, const float *value)
void minmax_object(Object *ob, float *min, float *max)
{
BoundBox bb;
- Mesh *me;
- Curve *cu;
float vec[3];
int a;
+ short change= FALSE;
switch(ob->type) {
-
case OB_CURVE:
case OB_FONT:
case OB_SURF:
- cu= ob->data;
-
- if(cu->bb==NULL) tex_space_curve(cu);
- bb= *(cu->bb);
-
- for(a=0; a<8; a++) {
- mul_m4_v3(ob->obmat, bb.vec[a]);
- DO_MINMAX(bb.vec[a], min, max);
+ {
+ Curve *cu= ob->data;
+
+ if(cu->bb==NULL) tex_space_curve(cu);
+ bb= *(cu->bb);
+
+ for(a=0; a<8; a++) {
+ mul_m4_v3(ob->obmat, bb.vec[a]);
+ DO_MINMAX(bb.vec[a], min, max);
+ }
+ change= TRUE;
+ }
+ break;
+ case OB_LATTICE:
+ {
+ Lattice *lt= ob->data;
+ BPoint *bp= lt->def;
+ int u, v, w;
+
+ for(w=0; w<lt->pntsw; w++) {
+ for(v=0; v<lt->pntsv; v++) {
+ for(u=0; u<lt->pntsu; u++, bp++) {
+ mul_v3_m4v3(vec, ob->obmat, bp->vec);
+ DO_MINMAX(vec, min, max);
+ }
+ }
+ }
+ change= TRUE;
}
break;
case OB_ARMATURE:
@@ -2416,25 +2434,27 @@ void minmax_object(Object *ob, float *min, float *max)
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
DO_MINMAX(vec, min, max);
}
- break;
+ change= TRUE;
}
- /* no break, get_mesh will give NULL and it passes on to default */
+ break;
case OB_MESH:
- me= get_mesh(ob);
-
- if(me) {
- bb = *mesh_get_bb(ob);
-
- for(a=0; a<8; a++) {
- mul_m4_v3(ob->obmat, bb.vec[a]);
- DO_MINMAX(bb.vec[a], min, max);
+ {
+ Mesh *me= get_mesh(ob);
+
+ if(me) {
+ bb = *mesh_get_bb(ob);
+
+ for(a=0; a<8; a++) {
+ mul_m4_v3(ob->obmat, bb.vec[a]);
+ DO_MINMAX(bb.vec[a], min, max);
+ }
+ change= TRUE;
}
}
- if(min[0] < max[0] ) break;
-
- /* else here no break!!!, mesh can be zero sized */
-
- default:
+ break;
+ }
+
+ if(change == FALSE) {
DO_MINMAX(ob->obmat[3], min, max);
copy_v3_v3(vec, ob->obmat[3]);
@@ -2444,7 +2464,6 @@ void minmax_object(Object *ob, float *min, float *max)
copy_v3_v3(vec, ob->obmat[3]);
sub_v3_v3(vec, ob->size);
DO_MINMAX(vec, min, max);
- break;
}
}
@@ -2622,11 +2641,12 @@ void object_handle_update(Scene *scene, Object *ob)
#else /* ensure CD_MASK_BAREMESH for now */
EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
+ unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
if(em) {
- makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */
BKE_mesh_end_editmesh(ob->data, em);
} else
- makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH);
+ makeDerivedMesh(scene, ob, NULL, data_mask);
#endif
}
@@ -3037,9 +3057,14 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
if(newkey || from_mix==FALSE) {
kb= add_keyblock(key, name);
-
- /* create from lattice */
- latt_to_key(lt, kb);
+ if (!newkey) {
+ KeyBlock *basekb= (KeyBlock *)key->block.first;
+ kb->data= MEM_dupallocN(basekb->data);
+ kb->totelem= basekb->totelem;
+ }
+ else {
+ latt_to_key(lt, kb);
+ }
}
else {
/* copy from current values */
@@ -3075,7 +3100,10 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
KeyBlock *basekb= (KeyBlock *)key->block.first;
kb->data= MEM_dupallocN(basekb->data);
kb->totelem= basekb->totelem;
- } else curve_to_key(cu, kb, lb);
+ }
+ else {
+ curve_to_key(cu, kb, lb);
+ }
}
else {
/* copy from current values */
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 56f02762ea6..2dcefb98012 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -4027,7 +4027,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
init_particle_interpolation(sim->ob, psys, pa, &pind);
do_particle_interpolation(psys, p, pa, t, &pind, state);
- if(!keyed && !cached) {
+ if(pind.dm) {
+ mul_m4_v3(sim->ob->obmat, state->co);
+ mul_mat3_m4_v3(sim->ob->obmat, state->vel);
+ }
+ else if(!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) {
if((pa->flag & PARS_REKEY)==0) {
psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat);
mul_m4_v3(hairmat, state->co);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index fca8d470dc1..4e3840832bb 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1562,8 +1562,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
}
}
}
-/* sets particle to the emitter surface with initial velocity & rotation */
-void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
+void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra)
{
Object *ob = sim->ob;
ParticleSystem *psys = sim->psys;
@@ -1575,17 +1574,6 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
float q_phase[4];
int p = pa - psys->particles;
part=psys->part;
-
- /* get precise emitter matrix if particle is born */
- if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
- /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
- while(ob) {
- BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
- ob = ob->parent;
- }
- ob = sim->ob;
- where_is_object_time(sim->scene, ob, pa->time);
- }
/* get birth location from object */
if(part->tanfac != 0.f)
@@ -1594,7 +1582,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
/* get possible textural influence */
- psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra);
+ psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra);
/* particles live in global space so */
/* let's convert: */
@@ -1654,37 +1642,27 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
mat4_to_quat(rot,ob->obmat);
mul_qt_qtqt(r_rot,r_rot,rot);
}
-#if 0
- }
-#endif
if(part->phystype==PART_PHYS_BOIDS && pa->boid) {
- BoidParticle *bpa = pa->boid;
float dvec[3], q[4], mat[3][3];
- copy_v3_v3(pa->state.co,loc);
+ copy_v3_v3(state->co,loc);
/* boids don't get any initial velocity */
- zero_v3(pa->state.vel);
+ zero_v3(state->vel);
/* boids store direction in ave */
if(fabsf(nor[2])==1.0f) {
- sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]);
- normalize_v3(pa->state.ave);
+ sub_v3_v3v3(state->ave, loc, ob->obmat[3]);
+ normalize_v3(state->ave);
}
else {
- VECCOPY(pa->state.ave, nor);
+ VECCOPY(state->ave, nor);
}
- /* and gravity in r_ve */
- bpa->gravity[0] = bpa->gravity[1] = 0.0f;
- bpa->gravity[2] = -1.0f;
- if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
- && sim->scene->physics_settings.gravity[2]!=0.0f)
- bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
/* calculate rotation matrix */
- project_v3_v3v3(dvec, r_vel, pa->state.ave);
- sub_v3_v3v3(mat[0], pa->state.ave, dvec);
+ project_v3_v3v3(dvec, r_vel, state->ave);
+ sub_v3_v3v3(mat[0], state->ave, dvec);
normalize_v3(mat[0]);
negate_v3_v3(mat[2], r_vel);
normalize_v3(mat[2]);
@@ -1692,12 +1670,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* apply rotation */
mat3_to_quat_is_ok( q,mat);
- copy_qt_qt(pa->state.rot, q);
-
- bpa->data.health = part->boids->health;
- bpa->data.mode = eBoidMode_InAir;
- bpa->data.state_id = ((BoidState*)part->boids->states.first)->id;
- bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f;
+ copy_qt_qt(state->rot, q);
}
else {
/* conversion done so now we apply new: */
@@ -1710,7 +1683,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* *emitter velocity */
if(dtime != 0.f && part->obfac != 0.f){
- sub_v3_v3v3(vel, loc, pa->state.co);
+ sub_v3_v3v3(vel, loc, state->co);
mul_v3_fl(vel, part->obfac/dtime);
}
@@ -1747,13 +1720,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
if(part->partfac != 0.f)
madd_v3_v3fl(vel, p_vel, part->partfac);
- mul_v3_v3fl(pa->state.vel, vel, ptex.ivel);
+ mul_v3_v3fl(state->vel, vel, ptex.ivel);
/* -location from emitter */
- copy_v3_v3(pa->state.co,loc);
+ copy_v3_v3(state->co,loc);
/* -rotation */
- unit_qt(pa->state.rot);
+ unit_qt(state->rot);
if(part->rotmode){
/* create vector into which rotation is aligned */
@@ -1793,32 +1766,74 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
/* combine base rotation & phase */
- mul_qt_qtqt(pa->state.rot, rot, q_phase);
+ mul_qt_qtqt(state->rot, rot, q_phase);
}
/* -angular velocity */
- zero_v3(pa->state.ave);
+ zero_v3(state->ave);
if(part->avemode){
switch(part->avemode){
case PART_AVE_SPIN:
- copy_v3_v3(pa->state.ave, vel);
+ copy_v3_v3(state->ave, vel);
break;
case PART_AVE_RAND:
- copy_v3_v3(pa->state.ave, r_ave);
+ copy_v3_v3(state->ave, r_ave);
break;
}
- normalize_v3(pa->state.ave);
- mul_v3_fl(pa->state.ave,part->avefac);
+ normalize_v3(state->ave);
+ mul_v3_fl(state->ave, part->avefac);
}
}
+}
+/* sets particle to the emitter surface with initial velocity & rotation */
+void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
+{
+ Object *ob = sim->ob;
+ ParticleSystem *psys = sim->psys;
+ ParticleSettings *part;
+ ParticleTexture ptex;
+ int p = pa - psys->particles;
+ part=psys->part;
+
+ /* get precise emitter matrix if particle is born */
+ if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
+ /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
+ while(ob) {
+ BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
+ ob = ob->parent;
+ }
+ ob = sim->ob;
+ where_is_object_time(sim->scene, ob, pa->time);
+ }
+
+ psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra);
+
+ if(part->phystype==PART_PHYS_BOIDS && pa->boid) {
+ BoidParticle *bpa = pa->boid;
+
+ /* and gravity in r_ve */
+ bpa->gravity[0] = bpa->gravity[1] = 0.0f;
+ bpa->gravity[2] = -1.0f;
+ if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
+ && sim->scene->physics_settings.gravity[2]!=0.0f)
+ bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
+
+ bpa->data.health = part->boids->health;
+ bpa->data.mode = eBoidMode_InAir;
+ bpa->data.state_id = ((BoidState*)part->boids->states.first)->id;
+ bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f;
+ }
if(part->type == PART_HAIR){
pa->lifetime = 100.0f;
}
else{
+ /* get possible textural influence */
+ psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra);
+
pa->lifetime = part->lifetime * ptex.life;
if(part->randlife != 0.0f)
@@ -1904,6 +1919,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
PARTICLE_P;
ParticleKey *key;
int totpart = psys->totpart, k, totkeys = psys->totkeyed;
+ int keyed_flag = 0;
ksim.scene= sim->scene;
@@ -1933,6 +1949,8 @@ static void set_keyed_keys(ParticleSimulationData *sim)
for(k=0; k<totkeys; k++) {
ksim.ob = pt->ob ? pt->ob : sim->ob;
ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1);
+ keyed_flag = (ksim.psys->flag & PSYS_KEYED);
+ ksim.psys->flag &= ~PSYS_KEYED;
LOOP_PARTICLES {
key = pa->keys + k;
@@ -1956,6 +1974,8 @@ static void set_keyed_keys(ParticleSimulationData *sim)
if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f)
k++;
+ ksim.psys->flag |= keyed_flag;
+
pt = (pt->next && pt->next->flag & PTARGET_VALID)? pt->next : psys->targets.first;
}
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 16cef67ea6d..0d523599598 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -430,6 +430,7 @@ void init_actuator(bActuator *act)
act->data= MEM_callocN(sizeof(bCameraActuator), "camact");
ca = act->data;
ca->axis = ACT_CAMERA_X;
+ ca->damping = 1.0/32.0;
break;
case ACT_EDIT_OBJECT:
act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact");
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 791d572d385..51eaba3c05b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -468,6 +468,7 @@ Scene *add_scene(const char *name)
sce->r.ffcodecdata.audio_mixrate = 44100;
sce->r.ffcodecdata.audio_volume = 1.0f;
+ sce->r.ffcodecdata.audio_bitrate = 192;
BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine));
@@ -475,8 +476,7 @@ Scene *add_scene(const char *name)
sce->audio.doppler_factor = 1.0;
sce->audio.speed_of_sound = 343.3;
- strcpy(sce->r.backbuf, "//backbuf");
- strcpy(sce->r.pic, U.renderdir);
+ BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic));
BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
sce->r.osa= 8;
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index d2f05a8ca53..fbb5a77fa04 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1582,7 +1582,7 @@ typedef struct WipeZone {
static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo)
{
wipezone->flip = (wipe->angle < 0);
- wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/log(2.0f));
+ wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/M_LN2);
wipezone->xo = xo;
wipezone->yo = yo;
wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f));
@@ -3021,10 +3021,15 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
/* if not already done, load / initialize data */
get_sequence_effect(seq);
- if (!(force || seq->len != v->length || !v->frameMap)) {
+ if ( (force == FALSE) &&
+ (seq->len == v->length) &&
+ (v->frameMap != NULL)
+ ) {
return;
}
- if (!seq->seq1) { /* make coverity happy and check for (CID 598)
+ if ( (seq->seq1 == NULL) ||
+ (seq->len < 1)
+ ) { /* make coverity happy and check for (CID 598)
input strip ... */
return;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 30abb6278a7..b82ac69fc9e 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -587,8 +587,22 @@ void calc_sequence(Scene *scene, Sequence *seq)
if (seq->seq1) {
seq->start= seq->startdisp= MAX3(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
+ /* we cant help if strips don't overlap, it wont give useful results.
+ * but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
+ if(seq->enddisp < seq->startdisp) {
+ /* simple start/end swap */
+ seq->start= seq->enddisp;
+ seq->enddisp = seq->startdisp;
+ seq->startdisp= seq->start;
+ seq->flag |= SEQ_INVALID_EFFECT;
+ }
+ else {
+ seq->flag &= ~SEQ_INVALID_EFFECT;
+ }
+
seq->len= seq->enddisp - seq->startdisp;
- } else {
+ }
+ else {
calc_sequence_disp(scene, seq);
}
@@ -3207,26 +3221,30 @@ Sequence *seq_metastrip(ListBase * seqbase, Sequence * meta, Sequence *seq)
return NULL;
}
-int seq_swap(Sequence *seq_a, Sequence *seq_b)
+int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
{
char name[sizeof(seq_a->name)];
if(seq_a->len != seq_b->len)
+ *error_str= "Strips must be the same length";
return 0;
/* type checking, could be more advanced but disalow sound vs non-sound copy */
if(seq_a->type != seq_b->type) {
if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) {
+ *error_str= "Strips were not compatible";
return 0;
}
/* disallow effects to swap with non-effects strips */
if((seq_a->type & SEQ_EFFECT) != (seq_b->type & SEQ_EFFECT)) {
+ *error_str= "Strips were not compatible";
return 0;
}
if((seq_a->type & SEQ_EFFECT) && (seq_b->type & SEQ_EFFECT)) {
if(get_sequence_effect_num_inputs(seq_a->type) != get_sequence_effect_num_inputs(seq_b->type)) {
+ *error_str= "Strips must have the same number of inputs";
return 0;
}
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 40eb86f25be..da329503c9f 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -238,7 +238,7 @@ static void cleanup_textline(TextLine * tl)
int reopen_text(Text *text)
{
FILE *fp;
- int i, llen, len, res;
+ int i, llen, len;
unsigned char *buffer;
TextLine *tmp;
char str[FILE_MAXDIR+FILE_MAXFILE];
@@ -281,7 +281,7 @@ int reopen_text(Text *text)
fclose(fp);
- res= stat(str, &st);
+ stat(str, &st);
text->mtime= st.st_mtime;
text->nlines=0;
@@ -334,7 +334,7 @@ Text *add_text(const char *file, const char *relpath)
{
Main *bmain= G.main;
FILE *fp;
- int i, llen, len, res;
+ int i, llen, len;
unsigned char *buffer;
TextLine *tmp;
Text *ta;
@@ -374,7 +374,7 @@ Text *add_text(const char *file, const char *relpath)
fclose(fp);
- res= stat(str, &st);
+ stat(str, &st);
ta->mtime= st.st_mtime;
ta->nlines=0;
@@ -1236,14 +1236,11 @@ int txt_find_string(Text *text, char *findstr, int wrap, int match_case)
{
TextLine *tl, *startl;
char *s= NULL;
- int oldcl, oldsl;
if (!text || !text->curl || !text->sell) return 0;
txt_order_cursors(text);
- oldcl= txt_get_span(text->lines.first, text->curl);
- oldsl= txt_get_span(text->lines.first, text->sell);
tl= startl= text->sell;
if(match_case) s= strstr(&tl->line[text->selc], findstr);
@@ -2414,7 +2411,7 @@ static int txt_add_char_intern (Text *text, char add, int replace_tabs)
return 1;
}
- /* insert spaces rather then tabs */
+ /* insert spaces rather than tabs */
if (add == '\t' && replace_tabs) {
txt_convert_tab_to_spaces(text);
return 1;
@@ -2512,7 +2509,7 @@ void txt_indent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
- /* insert spaces rather then tabs */
+ /* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES){
add = tab_to_spaces;
indentlen = spaceslen;
@@ -2573,7 +2570,7 @@ void txt_unindent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
- /* insert spaces rather then tabs */
+ /* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES){
remove = tab_to_spaces;
indent = spaceslen;
@@ -2759,7 +2756,7 @@ int setcurr_tab_spaces (Text *text, int space)
break;
} else if (ch==':') {
is_indent = 1;
- } else if (ch==']' || ch=='}' || ch=='"' || ch=='\'') {
+ } else if (ch!=' ' && ch!='\t') {
is_indent = 0;
}
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 9cd07de31dc..64f3c111434 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -1191,6 +1191,28 @@ void set_current_material_texture(Material *ma, Tex *newtex)
}
}
+int has_current_material_texture(Material *ma)
+{
+ bNode *node;
+
+ if(ma && ma->use_nodes && ma->nodetree) {
+ node= nodeGetActiveID(ma->nodetree, ID_TE);
+
+ if(node) {
+ return 1;
+ }
+ else {
+ node= nodeGetActiveID(ma->nodetree, ID_MA);
+ if(node)
+ ma= (Material*)node->id;
+ else
+ ma= NULL;
+ }
+ }
+
+ return (ma != NULL);
+}
+
Tex *give_current_world_texture(World *world)
{
MTex *mtex= NULL;
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 9b1c3b2ddb8..c729565533f 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -39,19 +39,6 @@
#include <libswscale/swscale.h>
#include <libavcodec/opt.h>
-#if LIBAVFORMAT_VERSION_INT < (49 << 16)
-#define FFMPEG_OLD_FRAME_RATE 1
-#else
-#define FFMPEG_CODEC_IS_POINTER 1
-#define FFMPEG_CODEC_TIME_BASE 1
-#endif
-
-#if LIBAVFORMAT_VERSION_INT >= (52 << 16)
-#define OUTFILE_PB (outfile->pb)
-#else
-#define OUTFILE_PB (&outfile->pb)
-#endif
-
#if defined(WIN32) && (!(defined snprintf))
#define snprintf _snprintf
#endif
@@ -74,6 +61,8 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "ffmpeg_compat.h"
+
extern void do_init_ffmpeg(void);
static int ffmpeg_type = 0;
@@ -114,24 +103,12 @@ static void delete_picture(AVFrame* f)
}
}
-#ifdef FFMPEG_CODEC_IS_POINTER
-static AVCodecContext* get_codec_from_stream(AVStream* stream)
-{
- return stream->codec;
-}
-#else
-static AVCodecContext* get_codec_from_stream(AVStream* stream)
-{
- return &stream->codec;
-}
-#endif
-
static int write_audio_frame(void)
{
AVCodecContext* c = NULL;
AVPacket pkt;
- c = get_codec_from_stream(audio_stream);
+ c = audio_stream->codec;
av_init_packet(&pkt);
pkt.size = 0;
@@ -153,17 +130,15 @@ static int write_audio_frame(void)
if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
{
-#ifdef FFMPEG_CODEC_TIME_BASE
pkt.pts = av_rescale_q(c->coded_frame->pts,
- c->time_base, audio_stream->time_base);
-#else
- pkt.pts = c->coded_frame->pts;
-#endif
+ c->time_base, audio_stream->time_base);
fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
}
pkt.stream_index = audio_stream->index;
- pkt.flags |= PKT_FLAG_KEY;
+
+ pkt.flags |= AV_PKT_FLAG_KEY;
+
if (av_interleaved_write_frame(outfile, &pkt) != 0) {
fprintf(stderr, "Error writing audio packet!\n");
return -1;
@@ -263,10 +238,10 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports
{
int outsize = 0;
int ret, success= 1;
- AVCodecContext* c = get_codec_from_stream(video_stream);
-#ifdef FFMPEG_CODEC_TIME_BASE
+ AVCodecContext* c = video_stream->codec;
+
frame->pts = rd->cfra - rd->sfra;
-#endif
+
if (rd->mode & R_FIELDS) {
frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0);
}
@@ -278,19 +253,15 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports
av_init_packet(&packet);
if (c->coded_frame->pts != AV_NOPTS_VALUE) {
-#ifdef FFMPEG_CODEC_TIME_BASE
packet.pts = av_rescale_q(c->coded_frame->pts,
c->time_base,
video_stream->time_base);
-#else
- packet.pts = c->coded_frame->pts;
-#endif
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
} else {
fprintf(stderr, "Video Frame PTS: not set\n");
}
if (c->coded_frame->key_frame)
- packet.flags |= PKT_FLAG_KEY;
+ packet.flags |= AV_PKT_FLAG_KEY;
packet.stream_index = video_stream->index;
packet.data = video_buffer;
packet.size = outsize;
@@ -312,7 +283,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
{
uint8_t* rendered_frame;
- AVCodecContext* c = get_codec_from_stream(video_stream);
+ AVCodecContext* c = video_stream->codec;
int width = c->width;
int height = c->height;
AVFrame* rgb_frame;
@@ -396,7 +367,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
switch(prop->type) {
case IDP_STRING:
fprintf(stderr, "%s.\n", IDP_String(prop));
- rv = av_set_string(c, prop->name, IDP_String(prop));
+ av_set_string3(c, prop->name, IDP_String(prop), 1, &rv);
break;
case IDP_FLOAT:
fprintf(stderr, "%g.\n", IDP_Float(prop));
@@ -407,7 +378,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
if (param) {
if (IDP_Int(prop)) {
- rv = av_set_string(c, name, param);
+ av_set_string3(c, name, param, 1, &rv);
} else {
return;
}
@@ -459,9 +430,9 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
/* Set up the codec context */
- c = get_codec_from_stream(st);
+ c = st->codec;
c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_VIDEO;
+ c->codec_type = AVMEDIA_TYPE_VIDEO;
/* Get some values from the current render settings */
@@ -469,7 +440,6 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->width = rectx;
c->height = recty;
-#ifdef FFMPEG_CODEC_TIME_BASE
/* FIXME: Really bad hack (tm) for NTSC support */
if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
c->time_base.den = 2997;
@@ -482,20 +452,6 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->time_base.den = rd->frs_sec * 100000;
c->time_base.num = ((double) rd->frs_sec_base) * 100000;
}
-#else
- /* FIXME: Really bad hack (tm) for NTSC support */
- if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
- c->frame_rate = 2997;
- c->frame_rate_base = 100;
- } else if ((double) ((int) rd->frs_sec_base) ==
- rd->frs_sec_base) {
- c->frame_rate = rd->frs_sec;
- c->frame_rate_base = rd->frs_sec_base;
- } else {
- c->frame_rate = rd->frs_sec * 100000;
- c->frame_rate_base = ((double) rd->frs_sec_base)*100000;
- }
-#endif
c->gop_size = ffmpeg_gop_size;
c->bit_rate = ffmpeg_video_bitrate*1000;
@@ -519,7 +475,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->pix_fmt = PIX_FMT_YUV422P;
}
- if (codec_id == CODEC_ID_XVID) {
+ if (ffmpeg_type == FFMPEG_XVID) {
/* arghhhh ... */
c->pix_fmt = PIX_FMT_YUV420P;
c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X');
@@ -586,9 +542,9 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
st = av_new_stream(of, 1);
if (!st) return NULL;
- c = get_codec_from_stream(st);
+ c = st->codec;
c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_AUDIO;
+ c->codec_type = AVMEDIA_TYPE_AUDIO;
c->sample_rate = rd->ffcodecdata.audio_mixrate;
c->bit_rate = ffmpeg_audio_bitrate*1000;
@@ -666,13 +622,13 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
BKE_report(reports, RPT_ERROR, "No valid formats found.");
return 0;
}
- fmt = guess_format(NULL, exts[0], NULL);
+ fmt = av_guess_format(NULL, exts[0], NULL);
if (!fmt) {
BKE_report(reports, RPT_ERROR, "No valid formats found.");
return 0;
}
- of = av_alloc_format_context();
+ of = avformat_alloc_context();
if (!of) {
BKE_report(reports, RPT_ERROR, "Error opening output file");
return 0;
@@ -713,7 +669,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
fmt->video_codec = CODEC_ID_H264;
break;
case FFMPEG_XVID:
- fmt->video_codec = CODEC_ID_XVID;
+ fmt->video_codec = CODEC_ID_MPEG4;
break;
case FFMPEG_FLV:
fmt->video_codec = CODEC_ID_FLV1;
@@ -772,7 +728,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
return 0;
}
if (!(fmt->flags & AVFMT_NOFILE)) {
- if (url_fopen(&of->pb, name, URL_WRONLY) < 0) {
+ if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) {
BKE_report(reports, RPT_ERROR, "Could not open file for writing.");
return 0;
}
@@ -780,7 +736,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
av_write_header(of);
outfile = of;
- dump_format(of, 0, name, 1);
+ av_dump_format(of, 0, name, 1);
return 1;
}
@@ -807,7 +763,7 @@ void flush_ffmpeg(void)
int outsize = 0;
int ret = 0;
- AVCodecContext* c = get_codec_from_stream(video_stream);
+ AVCodecContext* c = video_stream->codec;
/* get the delayed frames */
while (1) {
AVPacket packet;
@@ -822,19 +778,15 @@ void flush_ffmpeg(void)
break;
}
if (c->coded_frame->pts != AV_NOPTS_VALUE) {
-#ifdef FFMPEG_CODEC_TIME_BASE
packet.pts = av_rescale_q(c->coded_frame->pts,
c->time_base,
video_stream->time_base);
-#else
- packet.pts = c->coded_frame->pts;
-#endif
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
} else {
fprintf(stderr, "Video Frame PTS: not set\n");
}
if (c->coded_frame->key_frame) {
- packet.flags |= PKT_FLAG_KEY;
+ packet.flags |= AV_PKT_FLAG_KEY;
}
packet.stream_index = video_stream->index;
packet.data = video_buffer;
@@ -845,7 +797,7 @@ void flush_ffmpeg(void)
break;
}
}
- avcodec_flush_buffers(get_codec_from_stream(video_stream));
+ avcodec_flush_buffers(video_stream->codec);
}
/* **********************************************************************
@@ -902,7 +854,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
if(audio_stream)
{
- AVCodecContext* c = get_codec_from_stream(audio_stream);
+ AVCodecContext* c = audio_stream->codec;
AUD_DeviceSpecs specs;
specs.channels = c->channels;
specs.format = AUD_FORMAT_S16;
@@ -945,7 +897,7 @@ int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty,
success= (avframe && write_video_frame(rd, avframe, reports));
if (ffmpeg_autosplit) {
- if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) {
+ if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) {
end_ffmpeg();
ffmpeg_autosplit_count++;
success &= start_ffmpeg_impl(rd, rectx, recty, reports);
@@ -974,7 +926,7 @@ void end_ffmpeg(void)
audio_mixdown_device = 0;
}
- if (video_stream && get_codec_from_stream(video_stream)) {
+ if (video_stream && video_stream->codec) {
fprintf(stderr, "Flushing delayed frames...\n");
flush_ffmpeg ();
}
@@ -985,8 +937,8 @@ void end_ffmpeg(void)
/* Close the video codec */
- if (video_stream && get_codec_from_stream(video_stream)) {
- avcodec_close(get_codec_from_stream(video_stream));
+ if (video_stream && video_stream->codec) {
+ avcodec_close(video_stream->codec);
printf("zero video stream %p\n", video_stream);
video_stream = 0;
}
@@ -1007,7 +959,7 @@ void end_ffmpeg(void)
}
if (outfile && outfile->oformat) {
if (!(outfile->oformat->flags & AVFMT_NOFILE)) {
- url_fclose(OUTFILE_PB);
+ avio_close(outfile->pb);
}
}
if (outfile) {
@@ -1101,12 +1053,12 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int
switch (o->type) {
case FF_OPT_TYPE_INT:
case FF_OPT_TYPE_INT64:
- val.i = o->default_val;
+ val.i = FFMPEG_DEF_OPT_VAL_INT(o);
idp_type = IDP_INT;
break;
case FF_OPT_TYPE_DOUBLE:
case FF_OPT_TYPE_FLOAT:
- val.f = o->default_val;
+ val.f = FFMPEG_DEF_OPT_VAL_DOUBLE(o);
idp_type = IDP_FLOAT;
break;
case FF_OPT_TYPE_STRING:
@@ -1314,7 +1266,7 @@ void ffmpeg_set_preset(RenderData *rd, int preset)
case FFMPEG_PRESET_XVID:
if(preset == FFMPEG_PRESET_XVID) {
rd->ffcodecdata.type = FFMPEG_AVI;
- rd->ffcodecdata.codec = CODEC_ID_XVID;
+ rd->ffcodecdata.codec = CODEC_ID_MPEG4;
}
else if(preset == FFMPEG_PRESET_THEORA) {
rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken
@@ -1357,7 +1309,7 @@ void ffmpeg_verify_image_type(RenderData *rd)
}
}
else if(rd->imtype == R_XVID) {
- if(rd->ffcodecdata.codec != CODEC_ID_XVID) {
+ if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID);
audio= 1;
}