Merge remote-tracking branch 'origin/master' into blender2.8

This commit is contained in:
Dalai Felinto 2017-01-11 09:44:25 +01:00
commit 77dcf0fbc5
19 changed files with 146 additions and 89 deletions

View File

@ -943,14 +943,16 @@ operator<<( std::ostream& os, const BasicVector::Vector3Dim<Scalar>& i )
{
#if 0
char buf[256];
#if _WIN32
sprintf(buf,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
#else
snprintf(buf,256,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
#endif
# if _WIN32
sprintf(buf,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
# else
snprintf(buf,256,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
# endif
os << std::string(buf);
#else
(void)i; /* Ignored. */
#endif
return os;
return os;
}

View File

@ -289,7 +289,6 @@ class RENDER_PT_embedded(RenderButtonsPanel, Panel):
row = layout.row()
row.operator("view3d.game_start", text="Start")
row.label()
row = layout.row()
row.label(text="Resolution:")
row = layout.row(align=True)
@ -310,8 +309,6 @@ class RENDER_PT_game_player(RenderButtonsPanel, Panel):
row = layout.row()
row.operator("wm.blenderplayer_start", text="Start")
row.label()
row = layout.row()
row.label(text="Resolution:")
row = layout.row(align=True)

View File

@ -752,8 +752,8 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
subsub.operator("particle.target_remove", icon='ZOOMOUT', text="")
sub = col.row()
subsub = sub.column(align=True)
subsub.operator("particle.target_move_up", icon='MOVE_UP_VEC', text="")
subsub.operator("particle.target_move_down", icon='MOVE_DOWN_VEC', text="")
subsub.operator("particle.target_move_up", icon='TRIA_UP', text="")
subsub.operator("particle.target_move_down", icon='TRIA_DOWN', text="")
key = psys.active_particle_target
if key:
@ -816,8 +816,8 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
#sub.operator("boid.state_add", icon='ZOOMIN', text="")
#sub.operator("boid.state_del", icon='ZOOMOUT', text="")
#sub = row.row(align=True)
#sub.operator("boid.state_move_up", icon='MOVE_UP_VEC', text="")
#sub.operator("boid.state_move_down", icon='MOVE_DOWN_VEC', text="")
#sub.operator("boid.state_move_up", icon='TRIA_UP', text="")
#sub.operator("boid.state_move_down", icon='TRIA_DOWN', text="")
state = boids.active_boid_state
@ -840,8 +840,8 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
subsub.operator("boid.rule_del", icon='ZOOMOUT', text="")
sub = col.row()
subsub = sub.column(align=True)
subsub.operator("boid.rule_move_up", icon='MOVE_UP_VEC', text="")
subsub.operator("boid.rule_move_down", icon='MOVE_DOWN_VEC', text="")
subsub.operator("boid.rule_move_up", icon='TRIA_UP', text="")
subsub.operator("boid.rule_move_down", icon='TRIA_DOWN', text="")
rule = state.active_boid_rule
@ -849,8 +849,8 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel):
row = layout.row()
row.prop(rule, "name", text="")
#somebody make nice icons for boids here please! -jahka
row.prop(rule, "use_in_air", icon='MOVE_UP_VEC', text="")
row.prop(rule, "use_on_land", icon='MOVE_DOWN_VEC', text="")
row.prop(rule, "use_in_air", icon='TRIA_UP', text="")
row.prop(rule, "use_on_land", icon='TRIA_DOWN', text="")
row = layout.row()
@ -1009,8 +1009,8 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
subsub = sub.column(align=True)
subsub.operator("particle.dupliob_copy", icon='ZOOMIN', text="")
subsub.operator("particle.dupliob_remove", icon='ZOOMOUT', text="")
subsub.operator("particle.dupliob_move_up", icon='MOVE_UP_VEC', text="")
subsub.operator("particle.dupliob_move_down", icon='MOVE_DOWN_VEC', text="")
subsub.operator("particle.dupliob_move_up", icon='TRIA_UP', text="")
subsub.operator("particle.dupliob_move_down", icon='TRIA_DOWN', text="")
weight = part.active_dupliweight
if weight:

View File

@ -90,6 +90,8 @@ void BKE_sound_create_scene(struct Scene *scene);
void BKE_sound_destroy_scene(struct Scene *scene);
void BKE_sound_reset_scene_specs(struct Scene *scene);
void BKE_sound_mute_scene(struct Scene *scene, int muted);
void BKE_sound_update_fps(struct Scene *scene);

View File

@ -562,8 +562,14 @@ void BKE_libblock_remap_locked(
default:
break;
}
/* Node trees may virtually use any kind of data-block... */
/* XXX Yuck!!!! nodetree update can do pretty much any thing when talking about py nodes,
* including creating new data-blocks (see T50385), so we need to unlock main here. :(
* Why can't we have re-entrent locks? */
BKE_main_unlock(bmain);
libblock_remap_data_postprocess_nodetree_update(bmain, new_id);
BKE_main_lock(bmain);
/* Full rebuild of DAG! */
DAG_relations_tag_update(bmain);

View File

@ -1909,19 +1909,19 @@ void BKE_mesh_calc_poly_center(
const MVert *mvarray, float r_cent[3])
{
if (mpoly->totloop == 3) {
cent_tri_v3(r_cent,
mvarray[loopstart[0].v].co,
mvarray[loopstart[1].v].co,
mvarray[loopstart[2].v].co
);
mid_v3_v3v3v3(r_cent,
mvarray[loopstart[0].v].co,
mvarray[loopstart[1].v].co,
mvarray[loopstart[2].v].co
);
}
else if (mpoly->totloop == 4) {
cent_quad_v3(r_cent,
mvarray[loopstart[0].v].co,
mvarray[loopstart[1].v].co,
mvarray[loopstart[2].v].co,
mvarray[loopstart[3].v].co
);
mid_v3_v3v3v3v3(r_cent,
mvarray[loopstart[0].v].co,
mvarray[loopstart[1].v].co,
mvarray[loopstart[2].v].co,
mvarray[loopstart[3].v].co
);
}
else {
mesh_calc_ngon_center(mpoly, loopstart, mvarray, r_cent);
@ -1978,7 +1978,7 @@ static float mesh_calc_poly_planar_area_centroid(
tri_area = area_tri_signed_v3(v1, v2, v3, normal);
total_area += tri_area;
cent_tri_v3(tri_cent, v1, v2, v3);
mid_v3_v3v3v3(tri_cent, v1, v2, v3);
madd_v3_v3fl(r_cent, tri_cent, tri_area);
copy_v3_v3(v2, v3);

View File

@ -246,6 +246,10 @@ bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type)
mti = modifierType_getInfo(modifier_type);
/* only geometry objects should be able to get modifiers [#25291] */
if (!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
return false;
}
if (ob->type == OB_LATTICE && (mti->flags & eModifierTypeFlag_AcceptsLattice) == 0) {
return false;

View File

@ -454,6 +454,16 @@ void BKE_sound_destroy_scene(struct Scene *scene)
AUD_destroySet(scene->speaker_handles);
}
void BKE_sound_reset_scene_specs(struct Scene *scene)
{
AUD_Specs specs;
specs.channels = AUD_Device_getChannels(sound_device);
specs.rate = AUD_Device_getRate(sound_device);
AUD_Sequence_setSpecs(scene->sound_scene, specs);
}
void BKE_sound_mute_scene(struct Scene *scene, int muted)
{
if (scene->sound_scene)
@ -580,15 +590,10 @@ void BKE_sound_update_sequencer(struct Main *main, bSound *sound)
static void sound_start_play_scene(struct Scene *scene)
{
AUD_Specs specs;
if (scene->playback_handle)
AUD_Handle_stop(scene->playback_handle);
specs.channels = AUD_Device_getChannels(sound_device);
specs.rate = AUD_Device_getRate(sound_device);
AUD_Sequence_setSpecs(scene->sound_scene, specs);
BKE_sound_reset_scene_specs(scene);
if ((scene->playback_handle = AUD_Device_play(sound_device, scene->sound_scene, 1)))
AUD_Handle_setLoopCount(scene->playback_handle, -1);
@ -910,6 +915,7 @@ void BKE_sound_delete_cache(struct bSound *UNUSED(sound)) {}
void BKE_sound_load(struct Main *UNUSED(bmain), struct bSound *UNUSED(sound)) {}
void BKE_sound_create_scene(struct Scene *UNUSED(scene)) {}
void BKE_sound_destroy_scene(struct Scene *UNUSED(scene)) {}
void BKE_sound_reset_scene_specs(struct Scene *UNUSED(scene)) {}
void BKE_sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
void *BKE_sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence),
int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }

View File

@ -444,7 +444,7 @@ static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop, AVDi
param = strchr(name, ':');
if (param) {
*param++ = 0;
*param++ = '\0';
}
switch (prop->type) {
@ -1114,7 +1114,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context, char *string, RenderData
BLI_make_existing_file(string);
autosplit[0] = 0;
autosplit[0] = '\0';
if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) {
if (context) {
@ -1137,7 +1137,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context, char *string, RenderData
strcat(string, *exts);
}
else {
*(string + strlen(string) - strlen(*fe)) = 0;
*(string + strlen(string) - strlen(*fe)) = '\0';
strcat(string, autosplit);
strcat(string, *fe);
}
@ -1267,7 +1267,7 @@ static void end_ffmpeg_impl(FFMpegContext *context, int is_autosplit)
if (is_autosplit == false) {
if (context->audio_mixdown_device) {
AUD_Device_free(context->audio_mixdown_device);
context->audio_mixdown_device = 0;
context->audio_mixdown_device = NULL;
}
}
#endif
@ -1283,50 +1283,50 @@ static void end_ffmpeg_impl(FFMpegContext *context, int is_autosplit)
/* Close the video codec */
if (context->video_stream && context->video_stream->codec) {
if (context->video_stream != NULL && context->video_stream->codec != NULL) {
avcodec_close(context->video_stream->codec);
PRINT("zero video stream %p\n", context->video_stream);
context->video_stream = 0;
context->video_stream = NULL;
}
if (context->audio_stream && context->audio_stream->codec) {
if (context->audio_stream != NULL && context->audio_stream->codec != NULL) {
avcodec_close(context->audio_stream->codec);
context->audio_stream = 0;
context->audio_stream = NULL;
}
/* free the temp buffer */
if (context->current_frame) {
if (context->current_frame != NULL) {
delete_picture(context->current_frame);
context->current_frame = 0;
context->current_frame = NULL;
}
if (context->outfile && context->outfile->oformat) {
if (context->outfile != NULL && context->outfile->oformat) {
if (!(context->outfile->oformat->flags & AVFMT_NOFILE)) {
avio_close(context->outfile->pb);
}
}
if (context->outfile) {
if (context->outfile != NULL) {
avformat_free_context(context->outfile);
context->outfile = 0;
context->outfile = NULL;
}
if (context->audio_input_buffer) {
if (context->audio_input_buffer != NULL) {
av_free(context->audio_input_buffer);
context->audio_input_buffer = 0;
context->audio_input_buffer = NULL;
}
#ifndef FFMPEG_HAVE_ENCODE_AUDIO2
if (context->audio_output_buffer) {
if (context->audio_output_buffer != NULL) {
av_free(context->audio_output_buffer);
context->audio_output_buffer = 0;
context->audio_output_buffer = NULL;
}
#endif
if (context->audio_deinterleave_buffer) {
if (context->audio_deinterleave_buffer != NULL) {
av_free(context->audio_deinterleave_buffer);
context->audio_deinterleave_buffer = 0;
context->audio_deinterleave_buffer = NULL;
}
if (context->img_convert_ctx) {
if (context->img_convert_ctx != NULL) {
sws_freeContext(context->img_convert_ctx);
context->img_convert_ctx = 0;
context->img_convert_ctx = NULL;
}
}
@ -1425,8 +1425,8 @@ static IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, con
int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char *str)
{
AVCodecContext c;
const AVOption *o = 0;
const AVOption *p = 0;
const AVOption *o = NULL;
const AVOption *p = NULL;
char name_[128];
char *name;
char *param;
@ -1445,7 +1445,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char
param = strchr(name, ' ');
}
if (param) {
*param++ = 0;
*param++ = '\0';
while (*param == ' ') param++;
}

View File

@ -44,9 +44,6 @@ extern "C" {
/********************************** Polygons *********************************/
void cent_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
void cent_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
float normal_poly_v3(float r[3], const float verts[][3], unsigned int nr);

View File

@ -234,6 +234,7 @@ void mid_v3_v3v3(float r[3], const float a[3], const float b[3]);
void mid_v2_v2v2(float r[2], const float a[2], const float b[2]);
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]);
void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const unsigned int nbr);
void mid_v3_v3v3_angle_weighted(float r[3], const float a[3], const float b[3]);
void mid_v3_angle_weighted(float r[3]);

View File

@ -37,20 +37,6 @@
/********************************** Polygons *********************************/
void cent_tri_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3])
{
cent[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
cent[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
cent[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
}
void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
{
cent[0] = 0.25f * (v1[0] + v2[0] + v3[0] + v4[0]);
cent[1] = 0.25f * (v1[1] + v2[1] + v3[1] + v4[1]);
cent[2] = 0.25f * (v1[2] + v2[2] + v3[2] + v4[2]);
}
void cross_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
{
float n1[3], n2[3];

View File

@ -280,6 +280,16 @@ void mid_v3_v3v3v3v3(float v[3], const float v1[3], const float v2[3], const flo
v[2] = (v1[2] + v2[2] + v3[2] + v4[2]) / 4.0f;
}
void mid_v3_v3_array(float r[3], const float (*vec_arr)[3], const unsigned int nbr)
{
const float factor = 1.0f / (float)nbr;
zero_v3(r);
for (unsigned int i = 0; i < nbr; i++) {
madd_v3_v3fl(r, vec_arr[i], factor);
}
}
/**
* Specialized function for calculating normals.
* fastpath for:

View File

@ -339,7 +339,7 @@ static bool mdisp_in_mdispquad(
compute_mdisp_quad(l_dst, l_dst_f_center, v1, v2, v3, v4, e1, e2);
/* expand quad a bit */
cent_quad_v3(c, v1, v2, v3, v4);
mid_v3_v3v3v3v3(c, v1, v2, v3, v4);
sub_v3_v3(v1, c); sub_v3_v3(v2, c);
sub_v3_v3(v3, c); sub_v3_v3(v4, c);

View File

@ -125,6 +125,11 @@ typedef struct uiItem {
int flag;
} uiItem;
enum {
UI_ITEM_FIXED = 1 << 0,
UI_ITEM_MIN = 1 << 1,
};
typedef struct uiButtonItem {
uiItem item;
uiBut *but;
@ -232,6 +237,7 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X);
if (variable) {
layout->item.flag |= UI_ITEM_MIN;
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
/* it may seem odd that the icon only adds (UI_UNIT_X / 4)
* but taking margins into account its fine */
@ -2060,6 +2066,7 @@ static void ui_litem_estimate_row(uiLayout *litem)
{
uiItem *item;
int itemw, itemh;
bool min_size_flag = true;
litem->w = 0;
litem->h = 0;
@ -2067,12 +2074,26 @@ static void ui_litem_estimate_row(uiLayout *litem)
for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
if (item->type == ITEM_BUTTON) {
const uiBut *but = ((uiButtonItem *)item)->but;
const bool icon_only = (but->flag & UI_HAS_ICON) && (but->str == NULL || but->str[0] == '\0');
min_size_flag = min_size_flag && icon_only;
}
else {
min_size_flag = min_size_flag && (item->flag & UI_ITEM_MIN);
}
litem->w += itemw;
litem->h = MAX2(itemh, litem->h);
if (item->next)
litem->w += litem->space;
}
if (min_size_flag) {
litem->item.flag |= UI_ITEM_MIN;
}
}
static int ui_litem_min_width(int itemw)
@ -2113,7 +2134,7 @@ static void ui_litem_layout_row(uiLayout *litem)
newtotw = totw;
for (item = litem->items.first; item; item = item->next) {
if (item->flag)
if (item->flag & UI_ITEM_FIXED)
continue;
ui_item_size(item, &itemw, &itemh);
@ -2126,16 +2147,19 @@ static void ui_litem_layout_row(uiLayout *litem)
x += neww;
if ((neww < minw || itemw == minw) && w != 0) {
if ((neww < minw || itemw == minw || item->flag & UI_ITEM_MIN) && w != 0) {
/* fixed size */
item->flag = 1;
item->flag |= UI_ITEM_FIXED;
if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_MIN) {
minw = itemw;
}
fixedw += minw;
flag = 1;
newtotw -= itemw;
}
else {
/* keep free size */
item->flag = 0;
item->flag &= ~UI_ITEM_FIXED;
freew += itemw;
}
}
@ -2152,8 +2176,11 @@ static void ui_litem_layout_row(uiLayout *litem)
ui_item_size(item, &itemw, &itemh);
minw = ui_litem_min_width(itemw);
if (item->flag) {
if (item->flag & UI_ITEM_FIXED) {
/* fixed minimum size items */
if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_MIN) {
minw = itemw;
}
itemw = ui_item_fit(minw, fixedx, fixedw, min_ii(w, fixedw), !item->next, litem->alignment);
fixedx += itemw;
}
@ -2193,6 +2220,7 @@ static void ui_litem_estimate_column(uiLayout *litem)
{
uiItem *item;
int itemw, itemh;
bool min_size_flag = true;
litem->w = 0;
litem->h = 0;
@ -2200,12 +2228,26 @@ static void ui_litem_estimate_column(uiLayout *litem)
for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
if (item->type == ITEM_BUTTON) {
const uiBut *but = ((uiButtonItem *)item)->but;
const bool icon_only = (but->flag & UI_HAS_ICON) && (but->str == NULL || but->str[0] == '\0');
min_size_flag = min_size_flag && icon_only;
}
else {
min_size_flag = min_size_flag && (item->flag & UI_ITEM_MIN);
}
litem->w = MAX2(litem->w, itemw);
litem->h += itemh;
if (item->next)
litem->h += litem->space;
}
if (min_size_flag) {
litem->item.flag |= UI_ITEM_MIN;
}
}
static void ui_litem_layout_column(uiLayout *litem)

View File

@ -98,12 +98,12 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
ModifierData *md = NULL, *new_md = NULL;
const ModifierTypeInfo *mti = modifierType_getInfo(type);
/* only geometry objects should be able to get modifiers [#25291] */
if (!ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
/* Check compatibility of modifier [T25291, T50373]. */
if (!BKE_object_support_modifier_type_check(ob, type)) {
BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2);
return NULL;
}
if (mti->flags & eModifierTypeFlag_Single) {
if (modifiers_findByType(ob, type)) {
BKE_report(reports, RPT_WARNING, "Only one modifier of this type is allowed");

View File

@ -383,6 +383,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
result = AUD_mixdown(scene->sound_scene, SFRA * specs.rate / FPS, (EFRA - SFRA + 1) * specs.rate / FPS,
accuracy, filename, specs, container, codec, bitrate);
BKE_sound_reset_scene_specs(scene);
if (result) {
BKE_report(op->reports, RPT_ERROR, result);
return OPERATOR_CANCELLED;

View File

@ -329,7 +329,7 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a
if (vlr->v4)
mid_v3_v3v3(co, vlr->v1->co, vlr->v3->co);
else
cent_tri_v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co);
mid_v3_v3v3v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co);
if (obi->flag & R_TRANSFORMED)
mul_m4_v3(obi->mat, co);
@ -1245,7 +1245,7 @@ static void *exec_strandsurface_sample(void *data)
normal_quad_v3(n, co1, co2, co3, co4);
}
else {
cent_tri_v3(co, co1, co2, co3);
mid_v3_v3v3v3(co, co1, co2, co3);
normal_tri_v3(n, co1, co2, co3);
}
negate_v3(n);

View File

@ -74,6 +74,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_sequencer.h"
#include "BKE_sound.h"
#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */
#include "BKE_object.h"
@ -3791,6 +3792,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
re->flag &= ~R_ANIMATION;
BLI_callback_exec(re->main, (ID *)scene, G.is_break ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE);
BKE_sound_reset_scene_specs(scene);
/* UGLY WARNING */
G.is_rendering = false;