Cleanup: style, use braces for render
This commit is contained in:
parent
797539e76c
commit
f24bb62fc2
|
@ -139,8 +139,9 @@ static void store_bake_pixel(void *handle, int x, int y, float u, float v)
|
|||
void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask)
|
||||
{
|
||||
size_t i;
|
||||
if (!mask)
|
||||
if (!mask) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* only extend to pixels outside the mask area */
|
||||
for (i = 0; i < num_pixels; i++) {
|
||||
|
@ -155,9 +156,10 @@ void RE_bake_margin(ImBuf *ibuf, char *mask, const int margin)
|
|||
/* margin */
|
||||
IMB_filter_extend(ibuf, mask, margin);
|
||||
|
||||
if (ibuf->planes != R_IMF_PLANES_RGBA)
|
||||
if (ibuf->planes != R_IMF_PLANES_RGBA) {
|
||||
/* clear alpha added by filtering */
|
||||
IMB_rectfill_alpha(ibuf, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -690,8 +692,9 @@ void RE_bake_pixels_populate(Mesh *me,
|
|||
mloopuv = CustomData_get_layer_n(&me->ldata, CD_MTFACE, uv_id);
|
||||
}
|
||||
|
||||
if (mloopuv == NULL)
|
||||
if (mloopuv == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
bd.pixel_array = pixel_array;
|
||||
bd.zspan = MEM_callocN(sizeof(ZSpan) * bake_images->size, "bake zspan");
|
||||
|
@ -757,8 +760,9 @@ void RE_bake_pixels_populate(Mesh *me,
|
|||
static void normal_uncompress(float out[3], const float in[3])
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < 3; i++) {
|
||||
out[i] = 2.0f * in[i] - 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
static void normal_compress(float out[3],
|
||||
|
@ -849,10 +853,12 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
|
|||
offset = i * depth;
|
||||
|
||||
if (primitive_id == -1) {
|
||||
if (depth == 4)
|
||||
if (depth == 4) {
|
||||
copy_v4_fl4(&result[offset], 0.5f, 0.5f, 1.0f, 1.0f);
|
||||
else
|
||||
}
|
||||
else {
|
||||
copy_v3_fl3(&result[offset], 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -862,10 +868,12 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
|
|||
for (j = 0; j < 3; j++) {
|
||||
const TSpace *ts;
|
||||
|
||||
if (is_smooth)
|
||||
if (is_smooth) {
|
||||
normal_short_to_float_v3(normals[j], triangle->mverts[j]->no);
|
||||
else
|
||||
}
|
||||
else {
|
||||
normal[j] = triangle->normal[j];
|
||||
}
|
||||
|
||||
ts = triangle->tspace[j];
|
||||
copy_v3_v3(tangents[j], ts->tangent);
|
||||
|
@ -877,8 +885,9 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[],
|
|||
w = 1.0f - u - v;
|
||||
|
||||
/* normal */
|
||||
if (is_smooth)
|
||||
if (is_smooth) {
|
||||
interp_barycentric_tri_v3(normals, u, v, normal);
|
||||
}
|
||||
|
||||
/* tangent */
|
||||
interp_barycentric_tri_v3(tangents, u, v, tangent);
|
||||
|
@ -936,8 +945,9 @@ void RE_bake_normal_world_to_object(const BakePixel pixel_array[],
|
|||
size_t offset;
|
||||
float nor[3];
|
||||
|
||||
if (pixel_array[i].primitive_id == -1)
|
||||
if (pixel_array[i].primitive_id == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
offset = i * depth;
|
||||
normal_uncompress(nor, &result[offset]);
|
||||
|
@ -963,8 +973,9 @@ void RE_bake_normal_world_to_world(const BakePixel pixel_array[],
|
|||
size_t offset;
|
||||
float nor[3];
|
||||
|
||||
if (pixel_array[i].primitive_id == -1)
|
||||
if (pixel_array[i].primitive_id == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
offset = i * depth;
|
||||
normal_uncompress(nor, &result[offset]);
|
||||
|
@ -987,10 +998,12 @@ void RE_bake_ibuf_clear(Image *image, const bool is_tangent)
|
|||
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
|
||||
BLI_assert(ibuf);
|
||||
|
||||
if (is_tangent)
|
||||
if (is_tangent) {
|
||||
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
|
||||
else
|
||||
}
|
||||
else {
|
||||
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(image, ibuf, lock);
|
||||
}
|
||||
|
|
|
@ -85,8 +85,9 @@ void RE_engines_exit(void)
|
|||
BLI_remlink(&R_engines, type);
|
||||
|
||||
if (!(type->flag & RE_INTERNAL)) {
|
||||
if (type->ext.free)
|
||||
if (type->ext.free) {
|
||||
type->ext.free(type->ext.data);
|
||||
}
|
||||
|
||||
MEM_freeN(type);
|
||||
}
|
||||
|
@ -106,8 +107,9 @@ RenderEngineType *RE_engines_find(const char *idname)
|
|||
RenderEngineType *type;
|
||||
|
||||
type = BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname));
|
||||
if (!type)
|
||||
if (!type) {
|
||||
type = BLI_findstring(&R_engines, "BLENDER_EEVEE", offsetof(RenderEngineType, idname));
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
@ -194,10 +196,12 @@ RenderResult *RE_engine_begin_result(
|
|||
CLAMP(w, 0, re->result->rectx);
|
||||
CLAMP(h, 0, re->result->recty);
|
||||
|
||||
if (x + w > re->result->rectx)
|
||||
if (x + w > re->result->rectx) {
|
||||
w = re->result->rectx - x;
|
||||
if (y + h > re->result->recty)
|
||||
}
|
||||
if (y + h > re->result->recty) {
|
||||
h = re->result->recty - y;
|
||||
}
|
||||
|
||||
/* allocate a render result */
|
||||
disprect.xmin = x;
|
||||
|
@ -229,8 +233,9 @@ RenderResult *RE_engine_begin_result(
|
|||
|
||||
pa = get_part_from_result(re, result);
|
||||
|
||||
if (pa)
|
||||
if (pa) {
|
||||
pa->status = PART_STATUS_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -291,8 +296,9 @@ void RE_engine_end_result(
|
|||
render_result_exr_file_merge(re->result, result, re->viewname);
|
||||
}
|
||||
}
|
||||
else if (!(re->test_break(re->tbh) && (re->r.scemode & R_BUTS_PREVIEW)))
|
||||
else if (!(re->test_break(re->tbh) && (re->r.scemode & R_BUTS_PREVIEW))) {
|
||||
render_result_merge(re->result, result);
|
||||
}
|
||||
|
||||
/* draw */
|
||||
if (!re->test_break(re->tbh)) {
|
||||
|
@ -317,8 +323,9 @@ bool RE_engine_test_break(RenderEngine *engine)
|
|||
{
|
||||
Render *re = engine->re;
|
||||
|
||||
if (re)
|
||||
if (re) {
|
||||
return re->test_break(re->tbh);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -341,12 +348,15 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char
|
|||
/* set engine text */
|
||||
engine->text[0] = '\0';
|
||||
|
||||
if (stats && stats[0] && info && info[0])
|
||||
if (stats && stats[0] && info && info[0]) {
|
||||
BLI_snprintf(engine->text, sizeof(engine->text), "%s | %s", stats, info);
|
||||
else if (info && info[0])
|
||||
}
|
||||
else if (info && info[0]) {
|
||||
BLI_strncpy(engine->text, info, sizeof(engine->text));
|
||||
else if (stats && stats[0])
|
||||
}
|
||||
else if (stats && stats[0]) {
|
||||
BLI_strncpy(engine->text, stats, sizeof(engine->text));
|
||||
}
|
||||
}
|
||||
|
||||
void RE_engine_update_progress(RenderEngine *engine, float progress)
|
||||
|
@ -373,10 +383,12 @@ void RE_engine_report(RenderEngine *engine, int type, const char *msg)
|
|||
{
|
||||
Render *re = engine->re;
|
||||
|
||||
if (re)
|
||||
if (re) {
|
||||
BKE_report(engine->re->reports, type, msg);
|
||||
else if (engine->reports)
|
||||
}
|
||||
else if (engine->reports) {
|
||||
BKE_report(engine->reports, type, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void RE_engine_set_error_message(RenderEngine *engine, const char *msg)
|
||||
|
@ -412,8 +424,9 @@ float RE_engine_get_camera_shift_x(RenderEngine *engine, Object *camera, bool us
|
|||
|
||||
/* When using spherical stereo, get camera shift without multiview,
|
||||
* leaving stereo to be handled by the engine. */
|
||||
if (use_spherical_stereo)
|
||||
if (use_spherical_stereo) {
|
||||
re = NULL;
|
||||
}
|
||||
|
||||
return BKE_camera_multiview_shift_x(re ? &re->r : NULL, camera, re->viewname);
|
||||
}
|
||||
|
@ -427,8 +440,9 @@ void RE_engine_get_camera_model_matrix(RenderEngine *engine,
|
|||
|
||||
/* When using spherical stereo, get model matrix without multiview,
|
||||
* leaving stereo to be handled by the engine. */
|
||||
if (use_spherical_stereo)
|
||||
if (use_spherical_stereo) {
|
||||
re = NULL;
|
||||
}
|
||||
|
||||
BKE_camera_multiview_model_matrix(
|
||||
re ? &re->r : NULL, camera, re->viewname, (float(*)[4])r_modelmat);
|
||||
|
@ -593,8 +607,9 @@ bool RE_bake_engine(Render *re,
|
|||
engine->depsgraph = depsgraph;
|
||||
|
||||
/* update is only called so we create the engine.session */
|
||||
if (type->update)
|
||||
if (type->update) {
|
||||
type->update(engine, re->main, engine->depsgraph);
|
||||
}
|
||||
|
||||
type->bake(engine,
|
||||
engine->depsgraph,
|
||||
|
@ -625,8 +640,9 @@ bool RE_bake_engine(Render *re,
|
|||
RE_parts_free(re);
|
||||
BLI_rw_mutex_unlock(&re->partsmutex);
|
||||
|
||||
if (BKE_reports_contain(re->reports, RPT_ERROR))
|
||||
if (BKE_reports_contain(re->reports, RPT_ERROR)) {
|
||||
G.is_break = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -640,14 +656,18 @@ int RE_engine_render(Render *re, int do_all)
|
|||
bool persistent_data = (re->r.mode & R_PERSISTENT_DATA) != 0;
|
||||
|
||||
/* verify if we can render */
|
||||
if (!type->render)
|
||||
if (!type->render) {
|
||||
return 0;
|
||||
if ((re->r.scemode & R_BUTS_PREVIEW) && !(type->flag & RE_USE_PREVIEW))
|
||||
}
|
||||
if ((re->r.scemode & R_BUTS_PREVIEW) && !(type->flag & RE_USE_PREVIEW)) {
|
||||
return 0;
|
||||
if (do_all && !(type->flag & RE_USE_POSTPROCESS))
|
||||
}
|
||||
if (do_all && !(type->flag & RE_USE_POSTPROCESS)) {
|
||||
return 0;
|
||||
if (!do_all && (type->flag & RE_USE_POSTPROCESS))
|
||||
}
|
||||
if (!do_all && (type->flag & RE_USE_POSTPROCESS)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock drawing in UI during data phase. */
|
||||
if (re->draw_lock) {
|
||||
|
@ -665,11 +685,13 @@ int RE_engine_render(Render *re, int do_all)
|
|||
if (re->result == NULL || !(re->r.scemode & R_BUTS_PREVIEW)) {
|
||||
int savebuffers = RR_USE_MEM;
|
||||
|
||||
if (re->result)
|
||||
if (re->result) {
|
||||
render_result_free(re->result);
|
||||
}
|
||||
|
||||
if ((type->flag & RE_USE_SAVE_BUFFERS) && (re->r.scemode & R_EXR_TILE_FILE))
|
||||
if ((type->flag & RE_USE_SAVE_BUFFERS) && (re->r.scemode & R_EXR_TILE_FILE)) {
|
||||
savebuffers = RR_USE_EXR;
|
||||
}
|
||||
re->result = render_result_new(re, &re->disprect, 0, savebuffers, RR_ALL_LAYERS, RR_ALL_VIEWS);
|
||||
}
|
||||
BLI_rw_mutex_unlock(&re->resultmutex);
|
||||
|
@ -705,10 +727,12 @@ int RE_engine_render(Render *re, int do_all)
|
|||
/* TODO: actually link to a parent which shouldn't happen */
|
||||
engine->re = re;
|
||||
|
||||
if (re->flag & R_ANIMATION)
|
||||
if (re->flag & R_ANIMATION) {
|
||||
engine->flag |= RE_ENGINE_ANIMATION;
|
||||
if (re->r.scemode & R_BUTS_PREVIEW)
|
||||
}
|
||||
if (re->r.scemode & R_BUTS_PREVIEW) {
|
||||
engine->flag |= RE_ENGINE_PREVIEW;
|
||||
}
|
||||
engine->camera_override = re->camera_override;
|
||||
|
||||
engine->resolution_x = re->winx;
|
||||
|
@ -718,8 +742,9 @@ int RE_engine_render(Render *re, int do_all)
|
|||
engine->tile_x = re->partx;
|
||||
engine->tile_y = re->party;
|
||||
|
||||
if (re->result->do_exr_tile)
|
||||
if (re->result->do_exr_tile) {
|
||||
render_result_exr_file_begin(re, engine);
|
||||
}
|
||||
|
||||
/* Clear UI drawing locks. */
|
||||
if (re->draw_lock) {
|
||||
|
@ -792,12 +817,14 @@ int RE_engine_render(Render *re, int do_all)
|
|||
RE_parts_free(re);
|
||||
BLI_rw_mutex_unlock(&re->partsmutex);
|
||||
|
||||
if (BKE_reports_contain(re->reports, RPT_ERROR))
|
||||
if (BKE_reports_contain(re->reports, RPT_ERROR)) {
|
||||
G.is_break = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_FREESTYLE
|
||||
if (re->r.mode & R_EDGE_FRS)
|
||||
if (re->r.mode & R_EDGE_FRS) {
|
||||
RE_RenderFreestyleExternal(re);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -116,21 +116,24 @@ int imagewrap(Tex *tex,
|
|||
retval = texres->nor ? 3 : 1;
|
||||
|
||||
/* quick tests */
|
||||
if (ibuf == NULL && ima == NULL)
|
||||
if (ibuf == NULL && ima == NULL) {
|
||||
return retval;
|
||||
}
|
||||
if (ima) {
|
||||
|
||||
/* hack for icon render */
|
||||
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima))
|
||||
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
|
||||
|
||||
ima->flag |= IMA_USED_FOR_RENDER;
|
||||
}
|
||||
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -157,15 +160,17 @@ int imagewrap(Tex *tex,
|
|||
/* pass */
|
||||
}
|
||||
else {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if ((tex->flag & TEX_CHECKER_EVEN) == 0) {
|
||||
if ((xs + ys) & 1) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
@ -181,40 +186,48 @@ int imagewrap(Tex *tex,
|
|||
|
||||
if (tex->extend == TEX_CLIPCUBE) {
|
||||
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y || texvec[2] < -1.0f || texvec[2] > 1.0f) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
|
||||
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (tex->extend == TEX_EXTEND) {
|
||||
if (x >= ibuf->x)
|
||||
if (x >= ibuf->x) {
|
||||
x = ibuf->x - 1;
|
||||
else if (x < 0)
|
||||
}
|
||||
else if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
x = x % ibuf->x;
|
||||
if (x < 0)
|
||||
if (x < 0) {
|
||||
x += ibuf->x;
|
||||
}
|
||||
}
|
||||
if (tex->extend == TEX_EXTEND) {
|
||||
if (y >= ibuf->y)
|
||||
if (y >= ibuf->y) {
|
||||
y = ibuf->y - 1;
|
||||
else if (y < 0)
|
||||
}
|
||||
else if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
y = y % ibuf->y;
|
||||
if (y < 0)
|
||||
if (y < 0) {
|
||||
y += ibuf->y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,8 +329,9 @@ int imagewrap(Tex *tex,
|
|||
texres->tb *= fx;
|
||||
}
|
||||
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
|
||||
BRICONTRGB;
|
||||
|
||||
|
@ -338,8 +352,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
|
|||
rf->xmax += (x2 - x1);
|
||||
}
|
||||
else {
|
||||
if (rf->xmax > x2)
|
||||
if (rf->xmax > x2) {
|
||||
rf->xmax = x2;
|
||||
}
|
||||
newrct = stack + *count;
|
||||
(*count)++;
|
||||
|
||||
|
@ -348,8 +363,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
|
|||
newrct->ymin = rf->ymin;
|
||||
newrct->ymax = rf->ymax;
|
||||
|
||||
if (newrct->xmin == newrct->xmax)
|
||||
if (newrct->xmin == newrct->xmax) {
|
||||
(*count)--;
|
||||
}
|
||||
|
||||
rf->xmin = x1;
|
||||
}
|
||||
|
@ -360,8 +376,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
|
|||
rf->xmax -= (x2 - x1);
|
||||
}
|
||||
else {
|
||||
if (rf->xmin < x1)
|
||||
if (rf->xmin < x1) {
|
||||
rf->xmin = x1;
|
||||
}
|
||||
newrct = stack + *count;
|
||||
(*count)++;
|
||||
|
||||
|
@ -370,8 +387,9 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
|
|||
newrct->ymin = rf->ymin;
|
||||
newrct->ymax = rf->ymax;
|
||||
|
||||
if (newrct->xmin == newrct->xmax)
|
||||
if (newrct->xmin == newrct->xmax) {
|
||||
(*count)--;
|
||||
}
|
||||
|
||||
rf->xmax = x2;
|
||||
}
|
||||
|
@ -394,8 +412,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
|
|||
rf->ymax += (y2 - y1);
|
||||
}
|
||||
else {
|
||||
if (rf->ymax > y2)
|
||||
if (rf->ymax > y2) {
|
||||
rf->ymax = y2;
|
||||
}
|
||||
newrct = stack + *count;
|
||||
(*count)++;
|
||||
|
||||
|
@ -404,8 +423,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
|
|||
newrct->xmin = rf->xmin;
|
||||
newrct->xmax = rf->xmax;
|
||||
|
||||
if (newrct->ymin == newrct->ymax)
|
||||
if (newrct->ymin == newrct->ymax) {
|
||||
(*count)--;
|
||||
}
|
||||
|
||||
rf->ymin = y1;
|
||||
}
|
||||
|
@ -416,8 +436,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
|
|||
rf->ymax -= (y2 - y1);
|
||||
}
|
||||
else {
|
||||
if (rf->ymin < y1)
|
||||
if (rf->ymin < y1) {
|
||||
rf->ymin = y1;
|
||||
}
|
||||
newrct = stack + *count;
|
||||
(*count)++;
|
||||
|
||||
|
@ -426,8 +447,9 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
|
|||
newrct->xmin = rf->xmin;
|
||||
newrct->xmax = rf->xmax;
|
||||
|
||||
if (newrct->ymin == newrct->ymax)
|
||||
if (newrct->ymin == newrct->ymax) {
|
||||
(*count)--;
|
||||
}
|
||||
|
||||
rf->ymax = y2;
|
||||
}
|
||||
|
@ -503,14 +525,18 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
|
|||
starty = (int)floor(rf->ymin);
|
||||
endy = (int)floor(rf->ymax);
|
||||
|
||||
if (startx < 0)
|
||||
if (startx < 0) {
|
||||
startx = 0;
|
||||
if (starty < 0)
|
||||
}
|
||||
if (starty < 0) {
|
||||
starty = 0;
|
||||
if (endx >= ibuf->x)
|
||||
}
|
||||
if (endx >= ibuf->x) {
|
||||
endx = ibuf->x - 1;
|
||||
if (endy >= ibuf->y)
|
||||
}
|
||||
if (endy >= ibuf->y) {
|
||||
endy = ibuf->y - 1;
|
||||
}
|
||||
|
||||
if (starty == endy && startx == endx) {
|
||||
ibuf_get_color(&texres->tr, ibuf, startx, starty);
|
||||
|
@ -525,10 +551,12 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
|
|||
/* pass */
|
||||
}
|
||||
else {
|
||||
if (y == starty)
|
||||
if (y == starty) {
|
||||
muly = 1.0f - (rf->ymin - y);
|
||||
if (y == endy)
|
||||
}
|
||||
if (y == endy) {
|
||||
muly = (rf->ymax - y);
|
||||
}
|
||||
}
|
||||
|
||||
if (startx == endx) {
|
||||
|
@ -545,10 +573,12 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
|
|||
else {
|
||||
for (x = startx; x <= endx; x++) {
|
||||
mulx = muly;
|
||||
if (x == startx)
|
||||
if (x == startx) {
|
||||
mulx *= 1.0f - (rf->xmin - x);
|
||||
if (x == endx)
|
||||
}
|
||||
if (x == endx) {
|
||||
mulx *= (rf->xmax - x);
|
||||
}
|
||||
|
||||
ibuf_get_color(col, ibuf, x, y);
|
||||
|
||||
|
@ -619,8 +649,9 @@ static void boxsample(ImBuf *ibuf,
|
|||
CLAMP(rf->xmin, 0.0f, ibuf->x - 1);
|
||||
CLAMP(rf->xmax, 0.0f, ibuf->x - 1);
|
||||
}
|
||||
else if (imaprepeat)
|
||||
else if (imaprepeat) {
|
||||
clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
|
||||
}
|
||||
else {
|
||||
alphaclip = clipx_rctf(rf, 0.0, (float)(ibuf->x));
|
||||
|
||||
|
@ -634,8 +665,9 @@ static void boxsample(ImBuf *ibuf,
|
|||
CLAMP(rf->ymin, 0.0f, ibuf->y - 1);
|
||||
CLAMP(rf->ymax, 0.0f, ibuf->y - 1);
|
||||
}
|
||||
else if (imaprepeat)
|
||||
else if (imaprepeat) {
|
||||
clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
|
||||
}
|
||||
else {
|
||||
alphaclip *= clipy_rctf(rf, 0.0, (float)(ibuf->y));
|
||||
|
||||
|
@ -656,23 +688,27 @@ static void boxsample(ImBuf *ibuf,
|
|||
texres->tr += opp * texr.tr;
|
||||
texres->tg += opp * texr.tg;
|
||||
texres->tb += opp * texr.tb;
|
||||
if (texres->talpha)
|
||||
if (texres->talpha) {
|
||||
texres->ta += opp * texr.ta;
|
||||
}
|
||||
rf++;
|
||||
}
|
||||
if (tot != 0.0f) {
|
||||
texres->tr /= tot;
|
||||
texres->tg /= tot;
|
||||
texres->tb /= tot;
|
||||
if (texres->talpha)
|
||||
if (texres->talpha) {
|
||||
texres->ta /= tot;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
boxsampleclip(ibuf, rf, texres);
|
||||
}
|
||||
|
||||
if (texres->talpha == 0)
|
||||
if (texres->talpha == 0) {
|
||||
texres->ta = 1.0;
|
||||
}
|
||||
|
||||
if (alphaclip != 1.0f) {
|
||||
/* premul it all */
|
||||
|
@ -747,8 +783,9 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
|
|||
|
||||
if (ibuf->rect_float) {
|
||||
const float *fp = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
|
||||
if (ibuf->channels == 1)
|
||||
if (ibuf->channels == 1) {
|
||||
col[0] = col[1] = col[2] = col[3] = *fp;
|
||||
}
|
||||
else {
|
||||
col[0] = fp[0];
|
||||
col[1] = fp[1];
|
||||
|
@ -946,8 +983,9 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
|
|||
}
|
||||
if (ibuf->mipmap[0] == NULL) {
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
if (ibuf->mipmap[0] == NULL)
|
||||
if (ibuf->mipmap[0] == NULL) {
|
||||
IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
|
||||
}
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
/* if no mipmap could be made, fall back on non-mipmap render */
|
||||
|
@ -992,8 +1030,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
retval = texres->nor ? 3 : 1;
|
||||
|
||||
/* quick tests */
|
||||
if (ibuf == NULL && ima == NULL)
|
||||
if (ibuf == NULL && ima == NULL) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (ima) { /* hack for icon render */
|
||||
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
|
||||
|
@ -1003,8 +1042,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
}
|
||||
|
||||
if ((ibuf == NULL) || ((ibuf->rect == NULL) && (ibuf->rect_float == NULL))) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1047,10 +1087,12 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
/* Make sure the filtersize is minimal in pixels
|
||||
* (normal, ref map can have miniature pixel dx/dy). */
|
||||
const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
|
||||
if (addval > minx)
|
||||
if (addval > minx) {
|
||||
minx = addval;
|
||||
if (addval > miny)
|
||||
}
|
||||
if (addval > miny) {
|
||||
miny = addval;
|
||||
}
|
||||
}
|
||||
else if (tex->filtersize != 1.f) {
|
||||
minx *= tex->filtersize;
|
||||
|
@ -1083,17 +1125,22 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
/* repeat and clip */
|
||||
|
||||
if (tex->extend == TEX_REPEAT) {
|
||||
if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR))
|
||||
if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) {
|
||||
extflag = TXC_EXTD;
|
||||
else if (tex->flag & TEX_REPEAT_XMIR)
|
||||
}
|
||||
else if (tex->flag & TEX_REPEAT_XMIR) {
|
||||
extflag = TXC_XMIR;
|
||||
else if (tex->flag & TEX_REPEAT_YMIR)
|
||||
}
|
||||
else if (tex->flag & TEX_REPEAT_YMIR) {
|
||||
extflag = TXC_YMIR;
|
||||
else
|
||||
}
|
||||
else {
|
||||
extflag = TXC_REPT;
|
||||
}
|
||||
}
|
||||
else if (tex->extend == TEX_EXTEND)
|
||||
else if (tex->extend == TEX_EXTEND) {
|
||||
extflag = TXC_EXTD;
|
||||
}
|
||||
|
||||
if (tex->extend == TEX_CHECKER) {
|
||||
int xs = (int)floorf(fx), ys = (int)floorf(fy);
|
||||
|
@ -1103,8 +1150,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
fy -= ys;
|
||||
}
|
||||
else if ((tex->flag & TEX_CHECKER_ODD) == 0 && (tex->flag & TEX_CHECKER_EVEN) == 0) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
else {
|
||||
|
@ -1124,13 +1172,15 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
}
|
||||
else {
|
||||
if ((tex->flag & TEX_CHECKER_ODD) == 0 && ((xs + ys) & 1) == 0) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
if ((tex->flag & TEX_CHECKER_EVEN) == 0 && (xs + ys) & 1) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
fx -= xs;
|
||||
|
@ -1150,15 +1200,17 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
if (tex->extend == TEX_CLIPCUBE) {
|
||||
if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f ||
|
||||
texvec[2] < -1.f || texvec[2] > 1.f) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
|
||||
if ((fx + minx) < 0.f || (fy + miny) < 0.f || (fx - minx) > 1.f || (fy - miny) > 1.f) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
@ -1184,10 +1236,12 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
/* brecht: added stupid clamping here, large dx/dy can give very large
|
||||
* filter sizes which take ages to render, it may be better to do this
|
||||
* more intelligently later in the code .. probably it's not noticeable */
|
||||
if (AFD.dxt[0] * AFD.dxt[0] + AFD.dxt[1] * AFD.dxt[1] > 2.0f * 2.0f)
|
||||
if (AFD.dxt[0] * AFD.dxt[0] + AFD.dxt[1] * AFD.dxt[1] > 2.0f * 2.0f) {
|
||||
mul_v2_fl(AFD.dxt, 2.0f / len_v2(AFD.dxt));
|
||||
if (AFD.dyt[0] * AFD.dyt[0] + AFD.dyt[1] * AFD.dyt[1] > 2.0f * 2.0f)
|
||||
}
|
||||
if (AFD.dyt[0] * AFD.dyt[0] + AFD.dyt[1] * AFD.dyt[1] > 2.0f * 2.0f) {
|
||||
mul_v2_fl(AFD.dyt, 2.0f / len_v2(AFD.dyt));
|
||||
}
|
||||
|
||||
/* choice: */
|
||||
if (tex->imaflag & TEX_MIPMAP) {
|
||||
|
@ -1216,8 +1270,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
fProbes = 2.f * (a / b) - 1.f;
|
||||
AFD.iProbes = round_fl_to_int(fProbes);
|
||||
AFD.iProbes = MIN2(AFD.iProbes, tex->afmax);
|
||||
if (AFD.iProbes < fProbes)
|
||||
if (AFD.iProbes < fProbes) {
|
||||
b = 2.f * a / (float)(AFD.iProbes + 1);
|
||||
}
|
||||
AFD.majrad = a / ff;
|
||||
AFD.minrad = b / ff;
|
||||
AFD.theta = th;
|
||||
|
@ -1225,8 +1280,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
AFD.dvsc = ff / (float)ibuf->y;
|
||||
}
|
||||
else { /* EWA & area */
|
||||
if (ecc > (float)tex->afmax)
|
||||
if (ecc > (float)tex->afmax) {
|
||||
b = a / (float)tex->afmax;
|
||||
}
|
||||
b *= ff;
|
||||
}
|
||||
maxd = max_ff(b, 1e-8f);
|
||||
|
@ -1237,8 +1293,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
mipmaps[0] = ibuf;
|
||||
while (curmap < IMB_MIPMAP_LEVELS) {
|
||||
mipmaps[curmap + 1] = ibuf->mipmap[curmap];
|
||||
if (ibuf->mipmap[curmap])
|
||||
if (ibuf->mipmap[curmap]) {
|
||||
maxlev++;
|
||||
}
|
||||
curmap++;
|
||||
}
|
||||
|
||||
|
@ -1250,8 +1307,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
else if (levf >= maxlev - 1) {
|
||||
previbuf = curibuf = mipmaps[maxlev - 1];
|
||||
levf = 0.f;
|
||||
if (tex->texfilter == TXF_FELINE)
|
||||
if (tex->texfilter == TXF_FELINE) {
|
||||
AFD.iProbes = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const int lev = isnan(levf) ? 0 : (int)levf;
|
||||
|
@ -1323,8 +1381,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
fProbes = 2.f * (a / b) - 1.f;
|
||||
/* no limit to number of Probes here */
|
||||
AFD.iProbes = round_fl_to_int(fProbes);
|
||||
if (AFD.iProbes < fProbes)
|
||||
if (AFD.iProbes < fProbes) {
|
||||
b = 2.f * a / (float)(AFD.iProbes + 1);
|
||||
}
|
||||
AFD.majrad = a / ff;
|
||||
AFD.minrad = b / ff;
|
||||
AFD.theta = th;
|
||||
|
@ -1351,12 +1410,15 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
}
|
||||
}
|
||||
|
||||
if (tex->imaflag & TEX_CALCALPHA)
|
||||
if (tex->imaflag & TEX_CALCALPHA) {
|
||||
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
|
||||
else
|
||||
}
|
||||
else {
|
||||
texres->tin = texres->ta;
|
||||
if (tex->flag & TEX_NEGALPHA)
|
||||
}
|
||||
if (tex->flag & TEX_NEGALPHA) {
|
||||
texres->ta = 1.f - texres->ta;
|
||||
}
|
||||
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
|
||||
/* The invert of the red channel is to make
|
||||
|
@ -1385,8 +1447,9 @@ static int imagewraposa_aniso(Tex *tex,
|
|||
texres->tb *= fx;
|
||||
}
|
||||
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
|
||||
BRICONTRGB;
|
||||
|
||||
|
@ -1414,8 +1477,9 @@ int imagewraposa(Tex *tex,
|
|||
copy_v2_v2(dyt, DYT);
|
||||
|
||||
/* anisotropic filtering */
|
||||
if (tex->texfilter != TXF_BOX)
|
||||
if (tex->texfilter != TXF_BOX) {
|
||||
return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres, pool, skip_load_image);
|
||||
}
|
||||
|
||||
texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
|
||||
|
||||
|
@ -1423,21 +1487,24 @@ int imagewraposa(Tex *tex,
|
|||
retval = texres->nor ? 3 : 1;
|
||||
|
||||
/* quick tests */
|
||||
if (ibuf == NULL && ima == NULL)
|
||||
if (ibuf == NULL && ima == NULL) {
|
||||
return retval;
|
||||
}
|
||||
if (ima) {
|
||||
|
||||
/* hack for icon render */
|
||||
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima))
|
||||
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
|
||||
|
||||
ima->flag |= IMA_USED_FOR_RENDER;
|
||||
}
|
||||
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1479,10 +1546,12 @@ int imagewraposa(Tex *tex,
|
|||
* (normal, ref map can have miniature pixel dx/dy). */
|
||||
float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
|
||||
|
||||
if (addval > minx)
|
||||
if (addval > minx) {
|
||||
minx = addval;
|
||||
if (addval > miny)
|
||||
}
|
||||
if (addval > miny) {
|
||||
miny = addval;
|
||||
}
|
||||
}
|
||||
else if (tex->filtersize != 1.0f) {
|
||||
minx *= tex->filtersize;
|
||||
|
@ -1494,17 +1563,22 @@ int imagewraposa(Tex *tex,
|
|||
dyt[1] *= tex->filtersize;
|
||||
}
|
||||
|
||||
if (tex->imaflag & TEX_IMAROT)
|
||||
if (tex->imaflag & TEX_IMAROT) {
|
||||
SWAP(float, minx, miny);
|
||||
}
|
||||
|
||||
if (minx > 0.25f)
|
||||
if (minx > 0.25f) {
|
||||
minx = 0.25f;
|
||||
else if (minx < 0.00001f)
|
||||
}
|
||||
else if (minx < 0.00001f) {
|
||||
minx = 0.00001f; /* side faces of unit-cube */
|
||||
if (miny > 0.25f)
|
||||
}
|
||||
if (miny > 0.25f) {
|
||||
miny = 0.25f;
|
||||
else if (miny < 0.00001f)
|
||||
}
|
||||
else if (miny < 0.00001f) {
|
||||
miny = 0.00001f;
|
||||
}
|
||||
|
||||
/* repeat and clip */
|
||||
imaprepeat = (tex->extend == TEX_REPEAT);
|
||||
|
@ -1529,8 +1603,9 @@ int imagewraposa(Tex *tex,
|
|||
fy -= ys;
|
||||
}
|
||||
else if ((tex->flag & TEX_CHECKER_ODD) == 0 && (tex->flag & TEX_CHECKER_EVEN) == 0) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
else {
|
||||
|
@ -1547,15 +1622,17 @@ int imagewraposa(Tex *tex,
|
|||
/* pass */
|
||||
}
|
||||
else {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
if ((tex->flag & TEX_CHECKER_EVEN) == 0) {
|
||||
if ((xs + ys) & 1) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
@ -1564,26 +1641,34 @@ int imagewraposa(Tex *tex,
|
|||
}
|
||||
else {
|
||||
if (tex->flag & TEX_CHECKER_ODD) {
|
||||
if ((xs1 + ys) & 1)
|
||||
if ((xs1 + ys) & 1) {
|
||||
fx -= xs2;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fx -= xs1;
|
||||
}
|
||||
|
||||
if ((ys1 + xs) & 1)
|
||||
if ((ys1 + xs) & 1) {
|
||||
fy -= ys2;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fy -= ys1;
|
||||
}
|
||||
}
|
||||
if (tex->flag & TEX_CHECKER_EVEN) {
|
||||
if ((xs1 + ys) & 1)
|
||||
if ((xs1 + ys) & 1) {
|
||||
fx -= xs1;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fx -= xs2;
|
||||
}
|
||||
|
||||
if ((ys1 + xs) & 1)
|
||||
if ((ys1 + xs) & 1) {
|
||||
fy -= ys1;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fy -= ys2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1600,43 +1685,53 @@ int imagewraposa(Tex *tex,
|
|||
if (tex->extend == TEX_CLIPCUBE) {
|
||||
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f ||
|
||||
texvec[2] < -1.0f || texvec[2] > 1.0f) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else if (tex->extend == TEX_CLIP || tex->extend == TEX_CHECKER) {
|
||||
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f) {
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (imapextend) {
|
||||
if (fx > 1.0f)
|
||||
if (fx > 1.0f) {
|
||||
fx = 1.0f;
|
||||
else if (fx < 0.0f)
|
||||
}
|
||||
else if (fx < 0.0f) {
|
||||
fx = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fx > 1.0f)
|
||||
if (fx > 1.0f) {
|
||||
fx -= (int)(fx);
|
||||
else if (fx < 0.0f)
|
||||
}
|
||||
else if (fx < 0.0f) {
|
||||
fx += 1 - (int)(fx);
|
||||
}
|
||||
}
|
||||
|
||||
if (imapextend) {
|
||||
if (fy > 1.0f)
|
||||
if (fy > 1.0f) {
|
||||
fy = 1.0f;
|
||||
else if (fy < 0.0f)
|
||||
}
|
||||
else if (fy < 0.0f) {
|
||||
fy = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fy > 1.0f)
|
||||
if (fy > 1.0f) {
|
||||
fy -= (int)(fy);
|
||||
else if (fy < 0.0f)
|
||||
}
|
||||
else if (fy < 0.0f) {
|
||||
fy += 1 - (int)(fy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1648,22 +1743,26 @@ int imagewraposa(Tex *tex,
|
|||
dx = minx;
|
||||
dy = miny;
|
||||
maxd = max_ff(dx, dy);
|
||||
if (maxd > 0.5f)
|
||||
if (maxd > 0.5f) {
|
||||
maxd = 0.5f;
|
||||
}
|
||||
|
||||
pixsize = 1.0f / (float)MIN2(ibuf->x, ibuf->y);
|
||||
|
||||
bumpscale = pixsize / maxd;
|
||||
if (bumpscale > 1.0f)
|
||||
if (bumpscale > 1.0f) {
|
||||
bumpscale = 1.0f;
|
||||
else
|
||||
}
|
||||
else {
|
||||
bumpscale *= bumpscale;
|
||||
}
|
||||
|
||||
curmap = 0;
|
||||
previbuf = curibuf = ibuf;
|
||||
while (curmap < IMB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) {
|
||||
if (maxd < pixsize)
|
||||
if (maxd < pixsize) {
|
||||
break;
|
||||
}
|
||||
previbuf = curibuf;
|
||||
curibuf = ibuf->mipmap[curmap];
|
||||
pixsize = 1.0f / (float)MIN2(curibuf->x, curibuf->y);
|
||||
|
@ -1672,10 +1771,12 @@ int imagewraposa(Tex *tex,
|
|||
|
||||
if (previbuf != curibuf || (tex->imaflag & TEX_INTERPOL)) {
|
||||
/* sample at least 1 pixel */
|
||||
if (minx < 0.5f / ibuf->x)
|
||||
if (minx < 0.5f / ibuf->x) {
|
||||
minx = 0.5f / ibuf->x;
|
||||
if (miny < 0.5f / ibuf->y)
|
||||
}
|
||||
if (miny < 0.5f / ibuf->y) {
|
||||
miny = 0.5f / ibuf->y;
|
||||
}
|
||||
}
|
||||
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
|
||||
|
@ -1797,10 +1898,12 @@ int imagewraposa(Tex *tex,
|
|||
const int intpol = tex->imaflag & TEX_INTERPOL;
|
||||
if (intpol) {
|
||||
/* sample 1 pixel minimum */
|
||||
if (minx < 0.5f / ibuf->x)
|
||||
if (minx < 0.5f / ibuf->x) {
|
||||
minx = 0.5f / ibuf->x;
|
||||
if (miny < 0.5f / ibuf->y)
|
||||
}
|
||||
if (miny < 0.5f / ibuf->y) {
|
||||
miny = 0.5f / ibuf->y;
|
||||
}
|
||||
}
|
||||
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
|
||||
|
@ -1829,8 +1932,9 @@ int imagewraposa(Tex *tex,
|
|||
texres->nor[0] = (val1 - val2);
|
||||
texres->nor[1] = (val1 - val3);
|
||||
}
|
||||
else
|
||||
else {
|
||||
boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
|
||||
}
|
||||
}
|
||||
|
||||
if (tex->imaflag & TEX_CALCALPHA) {
|
||||
|
@ -1840,8 +1944,9 @@ int imagewraposa(Tex *tex,
|
|||
texres->tin = texres->ta;
|
||||
}
|
||||
|
||||
if (tex->flag & TEX_NEGALPHA)
|
||||
if (tex->flag & TEX_NEGALPHA) {
|
||||
texres->ta = 1.0f - texres->ta;
|
||||
}
|
||||
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
|
||||
/* qdn: normal from color
|
||||
|
@ -1862,8 +1967,9 @@ int imagewraposa(Tex *tex,
|
|||
mul_v3_fl(&texres->tr, 1.0f / texres->ta);
|
||||
}
|
||||
|
||||
if (ima)
|
||||
if (ima) {
|
||||
BKE_image_pool_release_ibuf(ima, ibuf, pool);
|
||||
}
|
||||
|
||||
BRICONTRGB;
|
||||
|
||||
|
|
|
@ -49,12 +49,15 @@
|
|||
|
||||
static float filt_quadratic(float x)
|
||||
{
|
||||
if (x < 0.0f)
|
||||
if (x < 0.0f) {
|
||||
x = -x;
|
||||
if (x < 0.5f)
|
||||
}
|
||||
if (x < 0.5f) {
|
||||
return 0.75f - (x * x);
|
||||
if (x < 1.5f)
|
||||
}
|
||||
if (x < 1.5f) {
|
||||
return 0.50f * (x - 1.5f) * (x - 1.5f);
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -62,13 +65,16 @@ static float filt_cubic(float x)
|
|||
{
|
||||
float x2 = x * x;
|
||||
|
||||
if (x < 0.0f)
|
||||
if (x < 0.0f) {
|
||||
x = -x;
|
||||
}
|
||||
|
||||
if (x < 1.0f)
|
||||
if (x < 1.0f) {
|
||||
return 0.5f * x * x2 - x2 + 2.0f / 3.0f;
|
||||
if (x < 2.0f)
|
||||
}
|
||||
if (x < 2.0f) {
|
||||
return (2.0f - x) * (2.0f - x) * (2.0f - x) / 6.0f;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -76,12 +82,15 @@ static float filt_catrom(float x)
|
|||
{
|
||||
float x2 = x * x;
|
||||
|
||||
if (x < 0.0f)
|
||||
if (x < 0.0f) {
|
||||
x = -x;
|
||||
if (x < 1.0f)
|
||||
}
|
||||
if (x < 1.0f) {
|
||||
return 1.5f * x2 * x - 2.5f * x2 + 1.0f;
|
||||
if (x < 2.0f)
|
||||
}
|
||||
if (x < 2.0f) {
|
||||
return -0.5f * x2 * x + 2.5f * x2 - 4.0f * x + 2.0f;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -96,16 +105,21 @@ static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */
|
|||
float q2 = (6.0f * b + 30.0f * c) / 6.0f;
|
||||
float q3 = (-b - 6.0f * c) / 6.0f;
|
||||
|
||||
if (x < -2.0f)
|
||||
if (x < -2.0f) {
|
||||
return 0.0f;
|
||||
if (x < -1.0f)
|
||||
}
|
||||
if (x < -1.0f) {
|
||||
return (q0 - x * (q1 - x * (q2 - x * q3)));
|
||||
if (x < 0.0f)
|
||||
}
|
||||
if (x < 0.0f) {
|
||||
return (p0 + x * x * (p2 - x * p3));
|
||||
if (x < 1.0f)
|
||||
}
|
||||
if (x < 1.0f) {
|
||||
return (p0 + x * x * (p2 + x * p3));
|
||||
if (x < 2.0f)
|
||||
}
|
||||
if (x < 2.0f) {
|
||||
return (q0 + x * (q1 + x * (q2 + x * q3)));
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -118,13 +132,15 @@ float RE_filter_value(int type, float x)
|
|||
|
||||
switch (type) {
|
||||
case R_FILTER_BOX:
|
||||
if (x > 1.0f)
|
||||
if (x > 1.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
return 1.0f;
|
||||
|
||||
case R_FILTER_TENT:
|
||||
if (x > 1.0f)
|
||||
if (x > 1.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
return 1.0f - x;
|
||||
|
||||
case R_FILTER_GAUSS: {
|
||||
|
@ -278,19 +294,23 @@ void RE_parts_init(Render *re)
|
|||
/* ensure we cover the entire picture, so last parts go to end */
|
||||
if (xd < xparts - 1) {
|
||||
disprect.xmax = disprect.xmin + partx;
|
||||
if (disprect.xmax > xmaxb)
|
||||
if (disprect.xmax > xmaxb) {
|
||||
disprect.xmax = xmaxb;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
disprect.xmax = xmaxb;
|
||||
}
|
||||
|
||||
if (yd < yparts - 1) {
|
||||
disprect.ymax = disprect.ymin + party;
|
||||
if (disprect.ymax > ymaxb)
|
||||
if (disprect.ymax > ymaxb) {
|
||||
disprect.ymax = ymaxb;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
disprect.ymax = ymaxb;
|
||||
}
|
||||
|
||||
rectx = BLI_rcti_size_x(&disprect);
|
||||
recty = BLI_rcti_size_y(&disprect);
|
||||
|
|
|
@ -251,8 +251,9 @@ static void rasterize_half(const MBakeRast *bake_rast,
|
|||
const int h = bake_rast->h;
|
||||
int y, y0, y1;
|
||||
|
||||
if (y1_in <= 0 || y0_in >= h)
|
||||
if (y1_in <= 0 || y0_in >= h) {
|
||||
return;
|
||||
}
|
||||
|
||||
y0 = y0_in < 0 ? 0 : y0_in;
|
||||
y1 = y1_in >= h ? h : y1_in;
|
||||
|
@ -263,8 +264,9 @@ static void rasterize_half(const MBakeRast *bake_rast,
|
|||
float x_l = s_stable != 0 ? (s0_s + (((s1_s - s0_s) * (y - t0_s)) / (t1_s - t0_s))) : s0_s;
|
||||
float x_r = l_stable != 0 ? (s0_l + (((s1_l - s0_l) * (y - t0_l)) / (t1_l - t0_l))) : s0_l;
|
||||
|
||||
if (is_mid_right != 0)
|
||||
if (is_mid_right != 0) {
|
||||
SWAP(float, x_l, x_r);
|
||||
}
|
||||
|
||||
iXl = (int)ceilf(x_l);
|
||||
iXr = (int)ceilf(x_r);
|
||||
|
@ -273,8 +275,9 @@ static void rasterize_half(const MBakeRast *bake_rast,
|
|||
iXl = iXl < 0 ? 0 : iXl;
|
||||
iXr = iXr >= w ? w : iXr;
|
||||
|
||||
for (x = iXl; x < iXr; x++)
|
||||
for (x = iXl; x < iXr; x++) {
|
||||
set_rast_triangle(bake_rast, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,8 +298,9 @@ static void bake_rasterize(const MBakeRast *bake_rast,
|
|||
int is_mid_right = 0, ylo, yhi, yhi_beg;
|
||||
|
||||
/* skip degenerates */
|
||||
if ((slo == smi && tlo == tmi) || (slo == shi && tlo == thi) || (smi == shi && tmi == thi))
|
||||
if ((slo == smi && tlo == tmi) || (slo == shi && tlo == thi) || (smi == shi && tmi == thi)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* sort by T */
|
||||
if (tlo > tmi && tlo > thi) {
|
||||
|
@ -389,12 +393,14 @@ static void *do_multires_bake_thread(void *data_v)
|
|||
const short mat_nr = mp->mat_nr;
|
||||
const MLoopUV *mloopuv = data->mloopuv;
|
||||
|
||||
if (multiresbake_test_break(bkr))
|
||||
if (multiresbake_test_break(bkr)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Image *tri_image = mat_nr < bkr->ob_image.len ? bkr->ob_image.array[mat_nr] : NULL;
|
||||
if (tri_image != handle->image)
|
||||
if (tri_image != handle->image) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->tri_index = tri_index;
|
||||
|
||||
|
@ -402,8 +408,9 @@ static void *do_multires_bake_thread(void *data_v)
|
|||
bake_rast, mloopuv[lt->tri[0]].uv, mloopuv[lt->tri[1]].uv, mloopuv[lt->tri[2]].uv);
|
||||
|
||||
/* tag image buffer for refresh */
|
||||
if (data->ibuf->rect_float)
|
||||
if (data->ibuf->rect_float) {
|
||||
data->ibuf->userflags |= IB_RECT_INVALID;
|
||||
}
|
||||
|
||||
data->ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
||||
|
||||
|
@ -411,13 +418,15 @@ static void *do_multires_bake_thread(void *data_v)
|
|||
BLI_spin_lock(&handle->queue->spin);
|
||||
bkr->baked_faces++;
|
||||
|
||||
if (bkr->do_update)
|
||||
if (bkr->do_update) {
|
||||
*bkr->do_update = true;
|
||||
}
|
||||
|
||||
if (bkr->progress)
|
||||
if (bkr->progress) {
|
||||
*bkr->progress = ((float)bkr->baked_objects +
|
||||
(float)bkr->baked_faces / handle->queue->tot_tri) /
|
||||
bkr->tot_obj;
|
||||
}
|
||||
BLI_spin_unlock(&handle->queue->spin);
|
||||
}
|
||||
|
||||
|
@ -476,18 +485,21 @@ static void do_multires_bake(MultiresBakeRender *bkr,
|
|||
void *bake_data = NULL;
|
||||
|
||||
if (require_tangent) {
|
||||
if (CustomData_get_layer_index(&dm->loopData, CD_TANGENT) == -1)
|
||||
if (CustomData_get_layer_index(&dm->loopData, CD_TANGENT) == -1) {
|
||||
DM_calc_loop_tangents(dm, true, NULL, 0);
|
||||
}
|
||||
|
||||
pvtangent = DM_get_loop_data_layer(dm, CD_TANGENT);
|
||||
}
|
||||
|
||||
/* all threads shares the same custom bake data */
|
||||
if (initBakeData)
|
||||
if (initBakeData) {
|
||||
bake_data = initBakeData(bkr, ima);
|
||||
}
|
||||
|
||||
if (tot_thread > 1)
|
||||
if (tot_thread > 1) {
|
||||
BLI_threadpool_init(&threads, do_multires_bake_thread, tot_thread);
|
||||
}
|
||||
|
||||
handles = MEM_callocN(tot_thread * sizeof(MultiresBakeThread), "do_multires_bake handles");
|
||||
|
||||
|
@ -528,15 +540,18 @@ static void do_multires_bake(MultiresBakeRender *bkr,
|
|||
|
||||
init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel, bkr->do_update);
|
||||
|
||||
if (tot_thread > 1)
|
||||
if (tot_thread > 1) {
|
||||
BLI_threadpool_insert(&threads, handle);
|
||||
}
|
||||
}
|
||||
|
||||
/* run threads */
|
||||
if (tot_thread > 1)
|
||||
if (tot_thread > 1) {
|
||||
BLI_threadpool_end(&threads);
|
||||
else
|
||||
}
|
||||
else {
|
||||
do_multires_bake_thread(&handles[0]);
|
||||
}
|
||||
|
||||
/* construct bake result */
|
||||
result->height_min = handles[0].height_min;
|
||||
|
@ -550,8 +565,9 @@ static void do_multires_bake(MultiresBakeRender *bkr,
|
|||
BLI_spin_end(&queue.spin);
|
||||
|
||||
/* finalize baking */
|
||||
if (freeBakeData)
|
||||
if (freeBakeData) {
|
||||
freeBakeData(bake_data);
|
||||
}
|
||||
|
||||
MEM_freeN(handles);
|
||||
|
||||
|
@ -658,11 +674,13 @@ static void get_ccgdm_data(DerivedMesh *lodm,
|
|||
CLAMP(crn_x, 0.0f, grid_size);
|
||||
CLAMP(crn_y, 0.0f, grid_size);
|
||||
|
||||
if (n != NULL)
|
||||
if (n != NULL) {
|
||||
interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 0, n);
|
||||
}
|
||||
|
||||
if (co != NULL)
|
||||
if (co != NULL) {
|
||||
interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 1, co);
|
||||
}
|
||||
}
|
||||
|
||||
/* mode = 0: interpolate normals,
|
||||
|
@ -727,9 +745,10 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
|
|||
DerivedMesh *lodm = bkr->lores_dm;
|
||||
BakeImBufuserData *userdata = ibuf->userdata;
|
||||
|
||||
if (userdata->displacement_buffer == NULL)
|
||||
if (userdata->displacement_buffer == NULL) {
|
||||
userdata->displacement_buffer = MEM_callocN(sizeof(float) * ibuf->x * ibuf->y,
|
||||
"MultiresBake heights");
|
||||
}
|
||||
|
||||
height_data = MEM_callocN(sizeof(MHeightBakeData), "MultiresBake heightData");
|
||||
|
||||
|
@ -747,8 +766,9 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
|
|||
smd.uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
|
||||
smd.quality = 3;
|
||||
|
||||
if (bkr->simple)
|
||||
if (bkr->simple) {
|
||||
smd.subdivType = ME_SIMPLE_SUBSURF;
|
||||
}
|
||||
|
||||
height_data->ssdm = subsurf_make_derived_from_derived(
|
||||
bkr->lores_dm, &smd, bkr->scene, NULL, 0);
|
||||
|
@ -767,8 +787,9 @@ static void free_heights_data(void *bake_data)
|
|||
{
|
||||
MHeightBakeData *height_data = (MHeightBakeData *)bake_data;
|
||||
|
||||
if (height_data->ssdm)
|
||||
if (height_data->ssdm) {
|
||||
height_data->ssdm->release(height_data->ssdm);
|
||||
}
|
||||
|
||||
MEM_freeN(height_data);
|
||||
}
|
||||
|
@ -1310,10 +1331,12 @@ static void bake_ibuf_normalize_displacement(
|
|||
if (*current_mask == FILTER_MASK_USED) {
|
||||
float normalized_displacement;
|
||||
|
||||
if (max_distance > 1e-5f)
|
||||
if (max_distance > 1e-5f) {
|
||||
normalized_displacement = (*current_displacement + max_distance) / (max_distance * 2);
|
||||
else
|
||||
}
|
||||
else {
|
||||
normalized_displacement = 0.5f;
|
||||
}
|
||||
|
||||
if (ibuf->rect_float) {
|
||||
/* currently baking happens to RGBA only */
|
||||
|
@ -1421,8 +1444,9 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
|
|||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
|
||||
BakeImBufuserData *userdata = (BakeImBufuserData *)ibuf->userdata;
|
||||
|
||||
if (ibuf->x <= 0 || ibuf->y <= 0)
|
||||
if (ibuf->x <= 0 || ibuf->y <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (use_displacement_buffer) {
|
||||
bake_ibuf_normalize_displacement(ibuf,
|
||||
|
@ -1436,8 +1460,9 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
|
|||
|
||||
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
|
||||
|
||||
if (ibuf->rect_float)
|
||||
if (ibuf->rect_float) {
|
||||
ibuf->userflags |= IB_RECT_INVALID;
|
||||
}
|
||||
|
||||
if (ibuf->mipmap[0]) {
|
||||
ibuf->userflags |= IB_MIPMAP_INVALID;
|
||||
|
@ -1445,8 +1470,9 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
|
|||
}
|
||||
|
||||
if (ibuf->userdata) {
|
||||
if (userdata->displacement_buffer)
|
||||
if (userdata->displacement_buffer) {
|
||||
MEM_freeN(userdata->displacement_buffer);
|
||||
}
|
||||
|
||||
MEM_freeN(userdata->mask_buffer);
|
||||
MEM_freeN(userdata);
|
||||
|
|
|
@ -186,10 +186,12 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
|
|||
mmap_used_memory,
|
||||
megs_peak_memory);
|
||||
|
||||
if (rs->curfield)
|
||||
if (rs->curfield) {
|
||||
fprintf(stdout, IFACE_("Field %d "), rs->curfield);
|
||||
if (rs->curblur)
|
||||
}
|
||||
if (rs->curblur) {
|
||||
fprintf(stdout, IFACE_("Blur %d "), rs->curblur);
|
||||
}
|
||||
|
||||
BLI_timecode_string_from_time_simple(
|
||||
info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
|
||||
|
@ -199,7 +201,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
|
|||
fprintf(stdout, "%s", rs->infostr);
|
||||
}
|
||||
else {
|
||||
if (rs->tothalo)
|
||||
if (rs->tothalo) {
|
||||
fprintf(stdout,
|
||||
IFACE_("Sce: %s Ve:%d Fa:%d Ha:%d La:%d"),
|
||||
rs->scene_name,
|
||||
|
@ -207,13 +209,15 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
|
|||
rs->totface,
|
||||
rs->tothalo,
|
||||
rs->totlamp);
|
||||
else
|
||||
}
|
||||
else {
|
||||
fprintf(stdout,
|
||||
IFACE_("Sce: %s Ve:%d Fa:%d La:%d"),
|
||||
rs->scene_name,
|
||||
rs->totvert,
|
||||
rs->totface,
|
||||
rs->totlamp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Flush stdout to be sure python callbacks are printing stuff after blender. */
|
||||
|
@ -331,9 +335,11 @@ Render *RE_GetRender(const char *name)
|
|||
Render *re;
|
||||
|
||||
/* search for existing renders */
|
||||
for (re = RenderGlobal.renderlist.first; re; re = re->next)
|
||||
if (STREQLEN(re->name, name, RE_MAXNAME))
|
||||
for (re = RenderGlobal.renderlist.first; re; re = re->next) {
|
||||
if (STREQLEN(re->name, name, RE_MAXNAME)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return re;
|
||||
}
|
||||
|
@ -377,15 +383,17 @@ void RE_SwapResult(Render *re, RenderResult **rr)
|
|||
|
||||
void RE_ReleaseResult(Render *re)
|
||||
{
|
||||
if (re)
|
||||
if (re) {
|
||||
BLI_rw_mutex_unlock(&re->resultmutex);
|
||||
}
|
||||
}
|
||||
|
||||
/* displist.c util.... */
|
||||
Scene *RE_GetScene(Render *re)
|
||||
{
|
||||
if (re)
|
||||
if (re) {
|
||||
return re->scene;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -486,11 +494,13 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
|
|||
rl = render_get_active_layer(re, re->result);
|
||||
|
||||
if (rl) {
|
||||
if (rv->rectf == NULL)
|
||||
if (rv->rectf == NULL) {
|
||||
rr->rectf = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, rv->name);
|
||||
}
|
||||
|
||||
if (rv->rectz == NULL)
|
||||
if (rv->rectz == NULL) {
|
||||
rr->rectz = RE_RenderLayerGetPass(rl, RE_PASSNAME_Z, rv->name);
|
||||
}
|
||||
}
|
||||
|
||||
rr->layers = re->result->layers;
|
||||
|
@ -506,8 +516,9 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr, const int view_id)
|
|||
|
||||
void RE_ReleaseResultImage(Render *re)
|
||||
{
|
||||
if (re)
|
||||
if (re) {
|
||||
BLI_rw_mutex_unlock(&re->resultmutex);
|
||||
}
|
||||
}
|
||||
|
||||
/* caller is responsible for allocating rect in correct size! */
|
||||
|
@ -607,10 +618,12 @@ void RE_InitRenderCB(Render *re)
|
|||
re->current_scene_update = current_scene_nothing;
|
||||
re->progress = float_nothing;
|
||||
re->test_break = default_break;
|
||||
if (G.background)
|
||||
if (G.background) {
|
||||
re->stats_draw = stats_background;
|
||||
else
|
||||
}
|
||||
else {
|
||||
re->stats_draw = stats_nothing;
|
||||
}
|
||||
/* clear callback handles */
|
||||
re->dih = re->dch = re->duh = re->sdh = re->prh = re->tbh = NULL;
|
||||
}
|
||||
|
@ -618,8 +631,9 @@ void RE_InitRenderCB(Render *re)
|
|||
/* only call this while you know it will remove the link too */
|
||||
void RE_FreeRender(Render *re)
|
||||
{
|
||||
if (re->engine)
|
||||
if (re->engine) {
|
||||
RE_engine_free(re->engine);
|
||||
}
|
||||
|
||||
BLI_rw_mutex_end(&re->resultmutex);
|
||||
BLI_rw_mutex_end(&re->partsmutex);
|
||||
|
@ -686,8 +700,9 @@ void RE_FreePersistentData(void)
|
|||
for (re = RenderGlobal.renderlist.first; re; re = re->next) {
|
||||
if (re->engine) {
|
||||
/* if engine is currently rendering, just tag it to be freed when render is finished */
|
||||
if (!(re->engine->flag & RE_ENGINE_RENDERING))
|
||||
if (!(re->engine->flag & RE_ENGINE_RENDERING)) {
|
||||
RE_engine_free(re->engine);
|
||||
}
|
||||
|
||||
re->engine = NULL;
|
||||
}
|
||||
|
@ -705,8 +720,9 @@ static int check_mode_full_sample(RenderData *rd)
|
|||
scemode &= ~R_FULL_SAMPLE;
|
||||
|
||||
#ifdef WITH_OPENEXR
|
||||
if (scemode & R_FULL_SAMPLE)
|
||||
if (scemode & R_FULL_SAMPLE) {
|
||||
scemode |= R_EXR_TILE_FILE; /* enable automatic */
|
||||
}
|
||||
#else
|
||||
/* can't do this without openexr support */
|
||||
scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
|
||||
|
@ -836,9 +852,11 @@ void RE_InitState(Render *re,
|
|||
RenderLayer *rl;
|
||||
bool have_layer = false;
|
||||
|
||||
for (rl = re->result->layers.first; rl; rl = rl->next)
|
||||
if (STREQ(rl->name, active_render_layer->name))
|
||||
for (rl = re->result->layers.first; rl; rl = rl->next) {
|
||||
if (STREQ(rl->name, active_render_layer->name)) {
|
||||
have_layer = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (re->result->rectx == re->rectx && re->result->recty == re->recty && have_layer) {
|
||||
/* keep render result, this avoids flickering black tiles
|
||||
|
@ -1256,17 +1274,22 @@ static int composite_needs_render(Scene *sce, int this_scene)
|
|||
bNodeTree *ntree = sce->nodetree;
|
||||
bNode *node;
|
||||
|
||||
if (ntree == NULL)
|
||||
if (ntree == NULL) {
|
||||
return 1;
|
||||
if (sce->use_nodes == false)
|
||||
}
|
||||
if (sce->use_nodes == false) {
|
||||
return 1;
|
||||
if ((sce->r.scemode & R_DOCOMP) == 0)
|
||||
}
|
||||
if ((sce->r.scemode & R_DOCOMP) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0)
|
||||
if (this_scene == 0 || node->id == NULL || node->id == &sce->id)
|
||||
if (node->type == CMP_NODE_R_LAYERS && (node->flag & NODE_MUTED) == 0) {
|
||||
if (this_scene == 0 || node->id == NULL || node->id == &sce->id) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1289,8 +1312,9 @@ static void ntree_render_scenes(Render *re)
|
|||
int cfra = re->scene->r.cfra;
|
||||
Scene *restore_scene = re->scene;
|
||||
|
||||
if (re->scene->nodetree == NULL)
|
||||
if (re->scene->nodetree == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* now foreach render-result node we do a full render */
|
||||
/* results are stored in a way compositor will find it */
|
||||
|
@ -1356,8 +1380,9 @@ static void add_freestyle(Render *re, int render)
|
|||
link = (LinkData *)MEM_callocN(sizeof(LinkData), "LinkData to Freestyle render");
|
||||
BLI_addtail(&re->freestyle_renders, link);
|
||||
|
||||
if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer)
|
||||
if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer) {
|
||||
continue;
|
||||
}
|
||||
if (FRS_is_freestyle_enabled(view_layer)) {
|
||||
r = FRS_do_stroke_rendering(re, view_layer, render);
|
||||
link->data = (void *)r;
|
||||
|
@ -1451,8 +1476,9 @@ static void do_render_composite(Render *re)
|
|||
|
||||
if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) {
|
||||
/* checks if there are render-result nodes that need scene */
|
||||
if ((re->r.scemode & R_SINGLE_LAYER) == 0)
|
||||
if ((re->r.scemode & R_SINGLE_LAYER) == 0) {
|
||||
ntree_render_scenes(re);
|
||||
}
|
||||
|
||||
if (!re->test_break(re->tbh)) {
|
||||
ntree->stats_draw = render_composit_stats;
|
||||
|
@ -1527,12 +1553,14 @@ int RE_seq_render_active(Scene *scene, RenderData *rd)
|
|||
|
||||
ed = scene->ed;
|
||||
|
||||
if (!(rd->scemode & R_DOSEQ) || !ed || !ed->seqbase.first)
|
||||
if (!(rd->scemode & R_DOSEQ) || !ed || !ed->seqbase.first) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (seq = ed->seqbase.first; seq; seq = seq->next) {
|
||||
if (seq->type != SEQ_TYPE_SOUND_RAM)
|
||||
if (seq->type != SEQ_TYPE_SOUND_RAM) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1614,8 +1642,9 @@ static void do_render_seq(Render *re)
|
|||
|
||||
if (recurs_depth == 0) { /* with nested scenes, only free on toplevel... */
|
||||
Editing *ed = re->scene->ed;
|
||||
if (ed)
|
||||
if (ed) {
|
||||
BKE_sequencer_free_imbuf(re->scene, &ed->seqbase, true);
|
||||
}
|
||||
}
|
||||
IMB_freeImBuf(ibuf_arr[view_id]);
|
||||
}
|
||||
|
@ -1639,10 +1668,12 @@ static void do_render_seq(Render *re)
|
|||
re->r.scemode |= R_DOSEQ;
|
||||
|
||||
/* set overall progress of sequence rendering */
|
||||
if (re->r.efra != re->r.sfra)
|
||||
if (re->r.efra != re->r.sfra) {
|
||||
re->progress(re->prh, (float)(cfra - re->r.sfra) / (re->r.efra - re->r.sfra));
|
||||
else
|
||||
}
|
||||
else {
|
||||
re->progress(re->prh, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
@ -1699,8 +1730,9 @@ static void do_render_all_options(Render *re)
|
|||
if (re->result != NULL) {
|
||||
camera = RE_GetCamera(re);
|
||||
/* sequence rendering should have taken care of that already */
|
||||
if (!(render_seq && (re->r.stamp & R_STAMP_STRIPMETA)))
|
||||
if (!(render_seq && (re->r.stamp & R_STAMP_STRIPMETA))) {
|
||||
BKE_render_result_stamp_info(re->scene, camera, re->result, false);
|
||||
}
|
||||
|
||||
/* stamp image info here */
|
||||
if ((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) {
|
||||
|
@ -1741,8 +1773,9 @@ static bool check_valid_camera_multiview(Scene *scene, Object *camera, ReportLis
|
|||
SceneRenderView *srv;
|
||||
bool active_view = false;
|
||||
|
||||
if (camera == NULL || (scene->r.scemode & R_MULTIVIEW) == 0)
|
||||
if (camera == NULL || (scene->r.scemode & R_MULTIVIEW) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
||||
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
|
||||
|
@ -1778,11 +1811,13 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList
|
|||
{
|
||||
const char *err_msg = "No camera found in scene \"%s\"";
|
||||
|
||||
if (camera_override == NULL && scene->camera == NULL)
|
||||
if (camera_override == NULL && scene->camera == NULL) {
|
||||
scene->camera = BKE_view_layer_camera_find(BKE_view_layer_default_render(scene));
|
||||
}
|
||||
|
||||
if (!check_valid_camera_multiview(scene, scene->camera, reports))
|
||||
if (!check_valid_camera_multiview(scene, scene->camera, reports)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RE_seq_render_active(scene, &scene->r)) {
|
||||
if (scene->ed) {
|
||||
|
@ -1803,8 +1838,9 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (!check_valid_camera_multiview(seq->scene, seq->scene_camera, reports))
|
||||
else if (!check_valid_camera_multiview(seq->scene, seq->scene_camera, reports)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
seq = seq->next;
|
||||
|
@ -2015,8 +2051,9 @@ static int render_initialize_from_main(Render *re,
|
|||
}
|
||||
|
||||
RE_InitState(re, NULL, &scene->r, &scene->view_layers, single_layer, winx, winy, &disprect);
|
||||
if (!re->ok) /* if an error was printed, abort */
|
||||
if (!re->ok) { /* if an error was printed, abort */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* initstate makes new result, have to send changed tags around */
|
||||
ntreeCompositTagRender(re->scene);
|
||||
|
@ -2101,8 +2138,9 @@ void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render
|
|||
{
|
||||
re->result_ok = 0;
|
||||
if (render_initialize_from_main(re, &scene->r, bmain, scene, NULL, NULL, 0, 0)) {
|
||||
if (render)
|
||||
if (render) {
|
||||
do_render_3d(re);
|
||||
}
|
||||
}
|
||||
re->result_ok = 1;
|
||||
}
|
||||
|
@ -2128,8 +2166,9 @@ bool RE_WriteRenderViewsImage(
|
|||
bool ok = true;
|
||||
RenderData *rd = &scene->r;
|
||||
|
||||
if (!rr)
|
||||
if (!rr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_mono = BLI_listbase_count_at_most(&rr->views, 2) < 2;
|
||||
bool is_exr_rr = ELEM(rd->im_format.imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) &&
|
||||
|
@ -2162,8 +2201,9 @@ bool RE_WriteRenderViewsImage(
|
|||
ImageFormatData imf = rd->im_format;
|
||||
imf.imtype = R_IMF_IMTYPE_JPEG90;
|
||||
|
||||
if (BLI_path_extension_check(name, ".exr"))
|
||||
if (BLI_path_extension_check(name, ".exr")) {
|
||||
name[strlen(name) - 4] = 0;
|
||||
}
|
||||
BKE_image_path_ensure_ext_from_imformat(name, &imf);
|
||||
|
||||
ImBuf *ibuf = render_result_rect_to_ibuf(rr, rd, view_id);
|
||||
|
@ -2222,8 +2262,9 @@ bool RE_WriteRenderViewsImage(
|
|||
ImageFormatData imf = rd->im_format;
|
||||
imf.imtype = R_IMF_IMTYPE_JPEG90;
|
||||
|
||||
if (BLI_path_extension_check(name, ".exr"))
|
||||
if (BLI_path_extension_check(name, ".exr")) {
|
||||
name[strlen(name) - 4] = 0;
|
||||
}
|
||||
|
||||
BKE_image_path_ensure_ext_from_imformat(name, &imf);
|
||||
ibuf_arr[2]->planes = 24;
|
||||
|
@ -2254,8 +2295,9 @@ bool RE_WriteRenderViewsMovie(ReportList *reports,
|
|||
bool is_mono;
|
||||
bool ok = true;
|
||||
|
||||
if (!rr)
|
||||
if (!rr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
is_mono = BLI_listbase_count_at_most(&rr->views, 2) < 2;
|
||||
|
||||
|
@ -2343,9 +2385,10 @@ static int do_write_image_or_movie(Render *re,
|
|||
re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, false);
|
||||
}
|
||||
else {
|
||||
if (name_override)
|
||||
if (name_override) {
|
||||
BLI_strncpy(name, name_override, sizeof(name));
|
||||
else
|
||||
}
|
||||
else {
|
||||
BKE_image_path_from_imformat(name,
|
||||
scene->r.pic,
|
||||
BKE_main_blendfile_path(bmain),
|
||||
|
@ -2354,6 +2397,7 @@ static int do_write_image_or_movie(Render *re,
|
|||
(scene->r.scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* write images as individual images or stereo */
|
||||
ok = RE_WriteRenderViewsImage(re->reports, &rres, scene, true, name);
|
||||
|
@ -2438,8 +2482,9 @@ void RE_BlenderAnim(Render *re,
|
|||
BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_INIT);
|
||||
|
||||
/* do not fully call for each frame, it initializes & pops output window */
|
||||
if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1))
|
||||
if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_movie) {
|
||||
size_t width, height;
|
||||
|
@ -2531,12 +2576,13 @@ void RE_BlenderAnim(Render *re,
|
|||
/* Skip this frame, but could update for physics and particles system. */
|
||||
continue;
|
||||
}
|
||||
else
|
||||
else {
|
||||
nfra += tfra;
|
||||
}
|
||||
|
||||
/* Touch/NoOverwrite options are only valid for image's */
|
||||
if (is_movie == false) {
|
||||
if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
|
||||
if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) {
|
||||
BKE_image_path_from_imformat(name,
|
||||
scene->r.pic,
|
||||
BKE_main_blendfile_path(bmain),
|
||||
|
@ -2545,6 +2591,7 @@ void RE_BlenderAnim(Render *re,
|
|||
(scene->r.scemode & R_EXTENSION) != 0,
|
||||
true,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (scene->r.mode & R_NO_OVERWRITE) {
|
||||
if (!is_multiview_name) {
|
||||
|
@ -2560,8 +2607,9 @@ void RE_BlenderAnim(Render *re,
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
||||
if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv))
|
||||
if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BKE_scene_multiview_filepath_get(srv, name, filepath);
|
||||
|
||||
|
@ -2590,8 +2638,9 @@ void RE_BlenderAnim(Render *re,
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
||||
if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv))
|
||||
if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BKE_scene_multiview_filepath_get(srv, name, filepath);
|
||||
|
||||
|
@ -2613,12 +2662,15 @@ void RE_BlenderAnim(Render *re,
|
|||
totrendered++;
|
||||
|
||||
if (re->test_break(re->tbh) == 0) {
|
||||
if (!G.is_break)
|
||||
if (!do_write_image_or_movie(re, bmain, scene, mh, totvideos, NULL))
|
||||
if (!G.is_break) {
|
||||
if (!do_write_image_or_movie(re, bmain, scene, mh, totvideos, NULL)) {
|
||||
G.is_break = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
G.is_break = true;
|
||||
}
|
||||
|
||||
if (G.is_break == true) {
|
||||
/* remove touched file */
|
||||
|
@ -2635,8 +2687,9 @@ void RE_BlenderAnim(Render *re,
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
||||
if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv))
|
||||
if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BKE_scene_multiview_filepath_get(srv, name, filepath);
|
||||
|
||||
|
@ -2665,8 +2718,9 @@ void RE_BlenderAnim(Render *re,
|
|||
re_movie_free_all(re, mh, totvideos);
|
||||
}
|
||||
|
||||
if (totskipped && totrendered == 0)
|
||||
if (totskipped && totrendered == 0) {
|
||||
BKE_report(re->reports, RPT_INFO, "No frames rendered, skipped to not overwrite");
|
||||
}
|
||||
|
||||
scene->r.cfra = cfrao;
|
||||
|
||||
|
@ -2730,13 +2784,15 @@ bool RE_ReadRenderResult(Scene *scene, Scene *scenode)
|
|||
disprect.ymax = winy;
|
||||
}
|
||||
|
||||
if (scenode)
|
||||
if (scenode) {
|
||||
scene = scenode;
|
||||
}
|
||||
|
||||
/* get render: it can be called from UI with draw callbacks */
|
||||
re = RE_GetSceneRender(scene);
|
||||
if (re == NULL)
|
||||
if (re == NULL) {
|
||||
re = RE_NewSceneRender(scene);
|
||||
}
|
||||
RE_InitState(re, NULL, &scene->r, &scene->view_layers, NULL, winx, winy, &disprect);
|
||||
re->scene = scene;
|
||||
|
||||
|
@ -2764,21 +2820,25 @@ void RE_layer_load_from_file(
|
|||
RenderPass *rpass = NULL;
|
||||
|
||||
/* multiview: since the API takes no 'view', we use the first combined pass found */
|
||||
for (rpass = layer->passes.first; rpass; rpass = rpass->next)
|
||||
if (STREQ(rpass->name, RE_PASSNAME_COMBINED))
|
||||
for (rpass = layer->passes.first; rpass; rpass = rpass->next) {
|
||||
if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rpass == NULL)
|
||||
if (rpass == NULL) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"%s: no Combined pass found in the render layer '%s'",
|
||||
__func__,
|
||||
filename);
|
||||
}
|
||||
|
||||
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
|
||||
if (ibuf->x == layer->rectx && ibuf->y == layer->recty) {
|
||||
if (ibuf->rect_float == NULL)
|
||||
if (ibuf->rect_float == NULL) {
|
||||
IMB_float_from_rect(ibuf);
|
||||
}
|
||||
|
||||
memcpy(rpass->rect, ibuf->rect_float, sizeof(float) * 4 * layer->rectx * layer->recty);
|
||||
}
|
||||
|
@ -2786,8 +2846,9 @@ void RE_layer_load_from_file(
|
|||
if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) {
|
||||
ImBuf *ibuf_clip;
|
||||
|
||||
if (ibuf->rect_float == NULL)
|
||||
if (ibuf->rect_float == NULL) {
|
||||
IMB_float_from_rect(ibuf);
|
||||
}
|
||||
|
||||
ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat);
|
||||
if (ibuf_clip) {
|
||||
|
@ -2857,10 +2918,12 @@ RenderPass *RE_pass_find_by_name(volatile RenderLayer *rl, const char *name, con
|
|||
|
||||
for (rp = rl->passes.last; rp; rp = rp->prev) {
|
||||
if (STREQ(rp->name, name)) {
|
||||
if (viewname == NULL || viewname[0] == '\0')
|
||||
if (viewname == NULL || viewname[0] == '\0') {
|
||||
break;
|
||||
else if (STREQ(rp->view, viewname))
|
||||
}
|
||||
else if (STREQ(rp->view, viewname)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rp;
|
||||
|
|
|
@ -99,33 +99,39 @@ static void point_data_pointers(PointDensity *pd,
|
|||
int offset = 0;
|
||||
|
||||
if (data_used & POINT_DATA_VEL) {
|
||||
if (r_data_velocity)
|
||||
if (r_data_velocity) {
|
||||
*r_data_velocity = data + offset;
|
||||
}
|
||||
offset += 3 * totpoint;
|
||||
}
|
||||
else {
|
||||
if (r_data_velocity)
|
||||
if (r_data_velocity) {
|
||||
*r_data_velocity = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (data_used & POINT_DATA_LIFE) {
|
||||
if (r_data_life)
|
||||
if (r_data_life) {
|
||||
*r_data_life = data + offset;
|
||||
}
|
||||
offset += totpoint;
|
||||
}
|
||||
else {
|
||||
if (r_data_life)
|
||||
if (r_data_life) {
|
||||
*r_data_life = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (data_used & POINT_DATA_COLOR) {
|
||||
if (r_data_color)
|
||||
if (r_data_color) {
|
||||
*r_data_color = data + offset;
|
||||
}
|
||||
offset += 3 * totpoint;
|
||||
}
|
||||
else {
|
||||
if (r_data_color)
|
||||
if (r_data_color) {
|
||||
*r_data_color = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,12 +209,15 @@ static void pointdensity_cache_psys(
|
|||
|
||||
if (psys->part->type == PART_HAIR) {
|
||||
/* hair particles */
|
||||
if (i < psys->totpart && psys->pathcache)
|
||||
if (i < psys->totpart && psys->pathcache) {
|
||||
cache = psys->pathcache[i];
|
||||
else if (i >= psys->totpart && psys->childcache)
|
||||
}
|
||||
else if (i >= psys->totpart && psys->childcache) {
|
||||
cache = psys->childcache[i - psys->totpart];
|
||||
else
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
|
||||
cache += cache->segments; /* use endpoint */
|
||||
|
||||
|
@ -220,8 +229,9 @@ static void pointdensity_cache_psys(
|
|||
/* emitter particles */
|
||||
state.time = cfra;
|
||||
|
||||
if (!psys_get_particle_state(&sim, i, &state, 0))
|
||||
if (!psys_get_particle_state(&sim, i, &state, 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data_used & POINT_DATA_LIFE) {
|
||||
if (i < psys->totpart) {
|
||||
|
@ -238,8 +248,9 @@ static void pointdensity_cache_psys(
|
|||
|
||||
copy_v3_v3(partco, state.co);
|
||||
|
||||
if (pd->psys_cache_space == TEX_PD_OBJECTSPACE)
|
||||
if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) {
|
||||
mul_m4_v3(ob->imat, partco);
|
||||
}
|
||||
else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) {
|
||||
sub_v3_v3(partco, ob->loc);
|
||||
}
|
||||
|
@ -280,12 +291,14 @@ static void pointdensity_cache_vertex_color(PointDensity *pd,
|
|||
|
||||
BLI_assert(data_color);
|
||||
|
||||
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPCOL))
|
||||
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPCOL)) {
|
||||
return;
|
||||
}
|
||||
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPCOL, pd->vertex_attribute_name, layername);
|
||||
mcol = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPCOL, layername);
|
||||
if (!mcol)
|
||||
if (!mcol) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Stores the number of MLoops using the same vertex, so we can normalize colors. */
|
||||
int *mcorners = MEM_callocN(sizeof(int) * pd->totpoints, "point density corner count");
|
||||
|
@ -309,8 +322,9 @@ static void pointdensity_cache_vertex_color(PointDensity *pd,
|
|||
* All the corners share the same vertex, ie. occupy the same point in space.
|
||||
*/
|
||||
for (i = 0; i < pd->totpoints; i++) {
|
||||
if (mcorners[i] > 0)
|
||||
if (mcorners[i] > 0) {
|
||||
mul_v3_fl(&data_color[i * 3], 1.0f / mcorners[i]);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(mcorners);
|
||||
|
@ -329,13 +343,16 @@ static void pointdensity_cache_vertex_weight(PointDensity *pd,
|
|||
BLI_assert(data_color);
|
||||
|
||||
mdef = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
|
||||
if (!mdef)
|
||||
if (!mdef) {
|
||||
return;
|
||||
}
|
||||
mdef_index = defgroup_name_index(ob, pd->vertex_attribute_name);
|
||||
if (mdef_index < 0)
|
||||
if (mdef_index < 0) {
|
||||
mdef_index = ob->actdef - 1;
|
||||
if (mdef_index < 0)
|
||||
}
|
||||
if (mdef_index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0, dv = mdef; i < totvert; ++i, ++dv, data_color += 3) {
|
||||
MDeformWeight *dw;
|
||||
|
@ -459,8 +476,9 @@ static void cache_pointdensity(Depsgraph *depsgraph, Scene *scene, PointDensity
|
|||
}
|
||||
else if (pd->source == TEX_PD_OBJECT) {
|
||||
Object *ob = pd->object;
|
||||
if (ob && ob->type == OB_MESH)
|
||||
if (ob && ob->type == OB_MESH) {
|
||||
pointdensity_cache_object(pd, ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,16 +538,20 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square
|
|||
density = sqrtf(dist);
|
||||
break;
|
||||
case TEX_PD_FALLOFF_PARTICLE_AGE:
|
||||
if (pdr->point_data_life)
|
||||
if (pdr->point_data_life) {
|
||||
density = dist * MIN2(pdr->point_data_life[index], 1.0f);
|
||||
else
|
||||
}
|
||||
else {
|
||||
density = dist;
|
||||
}
|
||||
break;
|
||||
case TEX_PD_FALLOFF_PARTICLE_VEL:
|
||||
if (pdr->point_data_velocity)
|
||||
if (pdr->point_data_velocity) {
|
||||
density = dist * len_v3(&pdr->point_data_velocity[index * 3]) * pdr->velscale;
|
||||
else
|
||||
}
|
||||
else {
|
||||
density = dist;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,14 +62,17 @@ static void render_result_views_free(RenderResult *res)
|
|||
RenderView *rv = res->views.first;
|
||||
BLI_remlink(&res->views, rv);
|
||||
|
||||
if (rv->rect32)
|
||||
if (rv->rect32) {
|
||||
MEM_freeN(rv->rect32);
|
||||
}
|
||||
|
||||
if (rv->rectz)
|
||||
if (rv->rectz) {
|
||||
MEM_freeN(rv->rectz);
|
||||
}
|
||||
|
||||
if (rv->rectf)
|
||||
if (rv->rectf) {
|
||||
MEM_freeN(rv->rectf);
|
||||
}
|
||||
|
||||
MEM_freeN(rv);
|
||||
}
|
||||
|
@ -79,25 +82,30 @@ static void render_result_views_free(RenderResult *res)
|
|||
|
||||
void render_result_free(RenderResult *res)
|
||||
{
|
||||
if (res == NULL)
|
||||
if (res == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (res->layers.first) {
|
||||
RenderLayer *rl = res->layers.first;
|
||||
|
||||
/* acolrect and scolrect are optionally allocated in shade_tile,
|
||||
* only free here since it can be used for drawing. */
|
||||
if (rl->acolrect)
|
||||
if (rl->acolrect) {
|
||||
MEM_freeN(rl->acolrect);
|
||||
if (rl->scolrect)
|
||||
}
|
||||
if (rl->scolrect) {
|
||||
MEM_freeN(rl->scolrect);
|
||||
if (rl->display_buffer)
|
||||
}
|
||||
if (rl->display_buffer) {
|
||||
MEM_freeN(rl->display_buffer);
|
||||
}
|
||||
|
||||
while (rl->passes.first) {
|
||||
RenderPass *rpass = rl->passes.first;
|
||||
if (rpass->rect)
|
||||
if (rpass->rect) {
|
||||
MEM_freeN(rpass->rect);
|
||||
}
|
||||
BLI_remlink(&rl->passes, rpass);
|
||||
MEM_freeN(rpass);
|
||||
}
|
||||
|
@ -107,16 +115,21 @@ void render_result_free(RenderResult *res)
|
|||
|
||||
render_result_views_free(res);
|
||||
|
||||
if (res->rect32)
|
||||
if (res->rect32) {
|
||||
MEM_freeN(res->rect32);
|
||||
if (res->rectz)
|
||||
}
|
||||
if (res->rectz) {
|
||||
MEM_freeN(res->rectz);
|
||||
if (res->rectf)
|
||||
}
|
||||
if (res->rectf) {
|
||||
MEM_freeN(res->rectf);
|
||||
if (res->text)
|
||||
}
|
||||
if (res->text) {
|
||||
MEM_freeN(res->text);
|
||||
if (res->error)
|
||||
}
|
||||
if (res->error) {
|
||||
MEM_freeN(res->error);
|
||||
}
|
||||
|
||||
BKE_stamp_data_free(res->stamp_data);
|
||||
|
||||
|
@ -131,8 +144,9 @@ void render_result_free_list(ListBase *lb, RenderResult *rr)
|
|||
for (; rr; rr = rrnext) {
|
||||
rrnext = rr->next;
|
||||
|
||||
if (lb && lb->first)
|
||||
if (lb && lb->first) {
|
||||
BLI_remlink(lb, rr);
|
||||
}
|
||||
|
||||
render_result_free(rr);
|
||||
}
|
||||
|
@ -145,8 +159,9 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src)
|
|||
{
|
||||
RenderView *rview;
|
||||
|
||||
if (dst == NULL || src == NULL)
|
||||
if (dst == NULL || src == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (rview = src->views.first; rview; rview = rview->next) {
|
||||
RenderView *rv;
|
||||
|
@ -164,8 +179,9 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src)
|
|||
/* free the views created temporarily */
|
||||
void render_result_views_shallowdelete(RenderResult *rr)
|
||||
{
|
||||
if (rr == NULL)
|
||||
if (rr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (rr->views.first) {
|
||||
RenderView *rv = rr->views.first;
|
||||
|
@ -248,13 +264,15 @@ static RenderPass *render_layer_add_pass(RenderResult *rr,
|
|||
if (STREQ(rpass->name, RE_PASSNAME_VECTOR)) {
|
||||
/* initialize to max speed */
|
||||
rect = rpass->rect;
|
||||
for (x = rectsize - 1; x >= 0; x--)
|
||||
for (x = rectsize - 1; x >= 0; x--) {
|
||||
rect[x] = PASS_VECTOR_MAX;
|
||||
}
|
||||
}
|
||||
else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
|
||||
rect = rpass->rect;
|
||||
for (x = rectsize - 1; x >= 0; x--)
|
||||
for (x = rectsize - 1; x >= 0; x--) {
|
||||
rect[x] = 10e10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,8 +306,9 @@ RenderResult *render_result_new(Render *re,
|
|||
rectx = BLI_rcti_size_x(partrct);
|
||||
recty = BLI_rcti_size_y(partrct);
|
||||
|
||||
if (rectx <= 0 || recty <= 0)
|
||||
if (rectx <= 0 || recty <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rr = MEM_callocN(sizeof(RenderResult), "new render result");
|
||||
rr->rectx = rectx;
|
||||
|
@ -342,12 +361,15 @@ RenderResult *render_result_new(Render *re,
|
|||
for (rv = rr->views.first; rv; rv = rv->next) {
|
||||
const char *view = rv->name;
|
||||
|
||||
if (viewname && viewname[0])
|
||||
if (!STREQ(view, viewname))
|
||||
if (viewname && viewname[0]) {
|
||||
if (!STREQ(view, viewname)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (rr->do_exr_tile)
|
||||
if (rr->do_exr_tile) {
|
||||
IMB_exr_add_view(rl->exrhandle, view);
|
||||
}
|
||||
|
||||
#define RENDER_LAYER_ADD_PASS_SAFE(rr, rl, channels, name, viewname, chan_id) \
|
||||
do { \
|
||||
|
@ -360,54 +382,78 @@ RenderResult *render_result_new(Render *re,
|
|||
/* a renderlayer should always have a Combined pass*/
|
||||
render_layer_add_pass(rr, rl, 4, "Combined", view, "RGBA");
|
||||
|
||||
if (view_layer->passflag & SCE_PASS_Z)
|
||||
if (view_layer->passflag & SCE_PASS_Z) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_Z, view, "Z");
|
||||
if (view_layer->passflag & SCE_PASS_VECTOR)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_VECTOR) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 4, RE_PASSNAME_VECTOR, view, "XYZW");
|
||||
if (view_layer->passflag & SCE_PASS_NORMAL)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_NORMAL) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_NORMAL, view, "XYZ");
|
||||
if (view_layer->passflag & SCE_PASS_UV)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_UV) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_UV, view, "UVA");
|
||||
if (view_layer->passflag & SCE_PASS_EMIT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_EMIT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_EMIT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_AO)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_AO) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_AO, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_ENVIRONMENT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_ENVIRONMENT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_ENVIRONMENT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_SHADOW)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_SHADOW) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SHADOW, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_INDEXOB)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_INDEXOB) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_INDEXOB, view, "X");
|
||||
if (view_layer->passflag & SCE_PASS_INDEXMA)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_INDEXMA) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_INDEXMA, view, "X");
|
||||
if (view_layer->passflag & SCE_PASS_MIST)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_MIST) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_MIST, view, "Z");
|
||||
if (rl->passflag & SCE_PASS_RAYHITS)
|
||||
}
|
||||
if (rl->passflag & SCE_PASS_RAYHITS) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 4, RE_PASSNAME_RAYHITS, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_DIFFUSE_DIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_DIFFUSE_DIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_DIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_DIFFUSE_INDIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_DIFFUSE_INDIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_INDIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_DIFFUSE_COLOR)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_DIFFUSE_COLOR) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_COLOR, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_GLOSSY_DIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_GLOSSY_DIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_DIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_GLOSSY_INDIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_GLOSSY_INDIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_INDIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_GLOSSY_COLOR)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_GLOSSY_COLOR) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_COLOR, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_TRANSM_DIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_TRANSM_DIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_DIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_TRANSM_INDIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_TRANSM_INDIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_INDIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_TRANSM_COLOR)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_TRANSM_COLOR) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_COLOR, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_SUBSURFACE_DIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_SUBSURFACE_DIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_DIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_SUBSURFACE_INDIRECT)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_SUBSURFACE_INDIRECT) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_INDIRECT, view, "RGB");
|
||||
if (view_layer->passflag & SCE_PASS_SUBSURFACE_COLOR)
|
||||
}
|
||||
if (view_layer->passflag & SCE_PASS_SUBSURFACE_COLOR) {
|
||||
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_COLOR, view, "RGB");
|
||||
}
|
||||
#undef RENDER_LAYER_ADD_PASS_SAFE
|
||||
}
|
||||
}
|
||||
|
@ -431,12 +477,15 @@ RenderResult *render_result_new(Render *re,
|
|||
for (rv = rr->views.first; rv; rv = rv->next) {
|
||||
const char *view = rv->name;
|
||||
|
||||
if (viewname && viewname[0])
|
||||
if (strcmp(view, viewname) != 0)
|
||||
if (viewname && viewname[0]) {
|
||||
if (strcmp(view, viewname) != 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (rr->do_exr_tile)
|
||||
if (rr->do_exr_tile) {
|
||||
IMB_exr_add_view(rl->exrhandle, view);
|
||||
}
|
||||
|
||||
/* a renderlayer should always have a Combined pass */
|
||||
render_layer_add_pass(rr, rl, 4, RE_PASSNAME_COMBINED, view, "RGBA");
|
||||
|
@ -504,15 +553,18 @@ void render_result_add_pass(RenderResult *rr,
|
|||
for (rv = rr->views.first; rv; rv = rv->next) {
|
||||
const char *view = rv->name;
|
||||
|
||||
if (viewname && viewname[0] && !STREQ(view, viewname))
|
||||
if (viewname && viewname[0] && !STREQ(view, viewname)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ensure that the pass doesn't exist yet. */
|
||||
for (rp = rl->passes.first; rp; rp = rp->next) {
|
||||
if (!STREQ(rp->name, name))
|
||||
if (!STREQ(rp->name, name)) {
|
||||
continue;
|
||||
if (!STREQ(rp->view, view))
|
||||
}
|
||||
if (!STREQ(rp->view, view)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -649,37 +701,47 @@ static int order_render_passes(const void *a, const void *b)
|
|||
unsigned int passtype_b = passtype_from_name(rpb->name);
|
||||
|
||||
/* Render passes with default type always go first. */
|
||||
if (passtype_b && !passtype_a)
|
||||
if (passtype_b && !passtype_a) {
|
||||
return 1;
|
||||
if (passtype_a && !passtype_b)
|
||||
}
|
||||
if (passtype_a && !passtype_b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (passtype_a && passtype_b) {
|
||||
if (passtype_a > passtype_b)
|
||||
if (passtype_a > passtype_b) {
|
||||
return 1;
|
||||
else if (passtype_a < passtype_b)
|
||||
}
|
||||
else if (passtype_a < passtype_b) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int cmp = strncmp(rpa->name, rpb->name, EXR_PASS_MAXNAME);
|
||||
if (cmp > 0)
|
||||
if (cmp > 0) {
|
||||
return 1;
|
||||
if (cmp < 0)
|
||||
}
|
||||
if (cmp < 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* they have the same type */
|
||||
/* left first */
|
||||
if (STREQ(rpa->view, STEREO_LEFT_NAME))
|
||||
if (STREQ(rpa->view, STEREO_LEFT_NAME)) {
|
||||
return 0;
|
||||
else if (STREQ(rpb->view, STEREO_LEFT_NAME))
|
||||
}
|
||||
else if (STREQ(rpb->view, STEREO_LEFT_NAME)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* right second */
|
||||
if (STREQ(rpa->view, STEREO_RIGHT_NAME))
|
||||
if (STREQ(rpa->view, STEREO_RIGHT_NAME)) {
|
||||
return 0;
|
||||
else if (STREQ(rpb->view, STEREO_RIGHT_NAME))
|
||||
}
|
||||
else if (STREQ(rpb->view, STEREO_RIGHT_NAME)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* remaining in ascending id order */
|
||||
return (rpa->view_id < rpb->view_id);
|
||||
|
@ -743,8 +805,9 @@ void render_result_views_new(RenderResult *rr, RenderData *rd)
|
|||
/* check renderdata for amount of views */
|
||||
if ((rd->scemode & R_MULTIVIEW)) {
|
||||
for (srv = rd->views.first; srv; srv = srv->next) {
|
||||
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
|
||||
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
|
||||
continue;
|
||||
}
|
||||
render_result_view_new(rr, srv->name);
|
||||
}
|
||||
}
|
||||
|
@ -813,8 +876,9 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart)
|
|||
for (rpass = rl->passes.first, rpassp = rlp->passes.first; rpass && rpassp;
|
||||
rpass = rpass->next) {
|
||||
/* renderresult have all passes, renderpart only the active view's passes */
|
||||
if (strcmp(rpassp->fullname, rpass->fullname) != 0)
|
||||
if (strcmp(rpassp->fullname, rpass->fullname) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels);
|
||||
|
||||
|
@ -1013,8 +1077,9 @@ void render_result_single_layer_end(Render *re)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!re->pushedresult)
|
||||
if (!re->pushedresult) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (re->pushedresult->rectx == re->result->rectx &&
|
||||
re->pushedresult->recty == re->result->recty) {
|
||||
|
@ -1242,8 +1307,9 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine)
|
|||
/* save part into exr file */
|
||||
void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart, const char *viewname)
|
||||
{
|
||||
for (; rr && rrpart; rr = rr->next, rrpart = rrpart->next)
|
||||
for (; rr && rrpart; rr = rr->next, rrpart = rrpart->next) {
|
||||
save_render_result_tile(rr, rrpart, viewname);
|
||||
}
|
||||
}
|
||||
|
||||
/* path to temporary exr file */
|
||||
|
@ -1282,17 +1348,20 @@ int render_result_exr_file_read_path(RenderResult *rr,
|
|||
}
|
||||
|
||||
if (rr == NULL || rectx != rr->rectx || recty != rr->recty) {
|
||||
if (rr)
|
||||
if (rr) {
|
||||
printf("error in reading render result: dimensions don't match\n");
|
||||
else
|
||||
}
|
||||
else {
|
||||
printf("error in reading render result: NULL result pointer\n");
|
||||
}
|
||||
IMB_exr_close(exrhandle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (rl = rr->layers.first; rl; rl = rl->next) {
|
||||
if (rl_single && rl_single != rl)
|
||||
if (rl_single && rl_single != rl) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* passes are allocated in sync */
|
||||
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
|
||||
|
@ -1438,8 +1507,9 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr,
|
|||
if (ibuf->rect_float) {
|
||||
rr->have_combined = true;
|
||||
|
||||
if (!rv->rectf)
|
||||
if (!rv->rectf) {
|
||||
rv->rectf = MEM_mallocN(4 * sizeof(float) * rr->rectx * rr->recty, "render_seq rectf");
|
||||
}
|
||||
|
||||
memcpy(rv->rectf, ibuf->rect_float, 4 * sizeof(float) * rr->rectx * rr->recty);
|
||||
|
||||
|
@ -1450,8 +1520,9 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr,
|
|||
else if (ibuf->rect) {
|
||||
rr->have_combined = true;
|
||||
|
||||
if (!rv->rect32)
|
||||
if (!rv->rect32) {
|
||||
rv->rect32 = MEM_mallocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
|
||||
}
|
||||
|
||||
memcpy(rv->rect32, ibuf->rect, 4 * rr->rectx * rr->recty);
|
||||
|
||||
|
@ -1464,12 +1535,15 @@ void render_result_rect_fill_zero(RenderResult *rr, const int view_id)
|
|||
{
|
||||
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
||||
|
||||
if (rv->rectf)
|
||||
if (rv->rectf) {
|
||||
memset(rv->rectf, 0, 4 * sizeof(float) * rr->rectx * rr->recty);
|
||||
else if (rv->rect32)
|
||||
}
|
||||
else if (rv->rect32) {
|
||||
memset(rv->rect32, 0, 4 * rr->rectx * rr->recty);
|
||||
else
|
||||
}
|
||||
else {
|
||||
rv->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
|
||||
}
|
||||
}
|
||||
|
||||
void render_result_rect_get_pixels(RenderResult *rr,
|
||||
|
@ -1482,9 +1556,10 @@ void render_result_rect_get_pixels(RenderResult *rr,
|
|||
{
|
||||
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
||||
|
||||
if (rv->rect32)
|
||||
if (rv->rect32) {
|
||||
memcpy(rect, rv->rect32, sizeof(int) * rr->rectx * rr->recty);
|
||||
else if (rv->rectf)
|
||||
}
|
||||
else if (rv->rectf) {
|
||||
IMB_display_buffer_transform_apply((unsigned char *)rect,
|
||||
rv->rectf,
|
||||
rr->rectx,
|
||||
|
@ -1493,9 +1568,11 @@ void render_result_rect_get_pixels(RenderResult *rr,
|
|||
view_settings,
|
||||
display_settings,
|
||||
true);
|
||||
else
|
||||
}
|
||||
else {
|
||||
/* else fill with black */
|
||||
memset(rect, 0, sizeof(int) * rectx * recty);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************** multiview functions *****************************/
|
||||
|
@ -1504,12 +1581,14 @@ bool RE_HasCombinedLayer(RenderResult *res)
|
|||
{
|
||||
RenderView *rv;
|
||||
|
||||
if (res == NULL)
|
||||
if (res == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rv = res->views.first;
|
||||
if (rv == NULL)
|
||||
if (rv == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (rv->rect32 || rv->rectf);
|
||||
}
|
||||
|
|
|
@ -121,17 +121,21 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
|
|||
}
|
||||
else if (tex->stype == TEX_QUAD) { /* quad */
|
||||
texres->tin = (1.0f + x) / 2.0f;
|
||||
if (texres->tin < 0.0f)
|
||||
if (texres->tin < 0.0f) {
|
||||
texres->tin = 0.0f;
|
||||
else
|
||||
}
|
||||
else {
|
||||
texres->tin *= texres->tin;
|
||||
}
|
||||
}
|
||||
else if (tex->stype == TEX_EASE) { /* ease */
|
||||
texres->tin = (1.0f + x) / 2.0f;
|
||||
if (texres->tin <= 0.0f)
|
||||
if (texres->tin <= 0.0f) {
|
||||
texres->tin = 0.0f;
|
||||
else if (texres->tin >= 1.0f)
|
||||
}
|
||||
else if (texres->tin >= 1.0f) {
|
||||
texres->tin = 1.0f;
|
||||
}
|
||||
else {
|
||||
t = texres->tin * texres->tin;
|
||||
texres->tin = (3.0f * t - 2.0f * t * texres->tin);
|
||||
|
@ -145,10 +149,12 @@ static int blend(Tex *tex, const float texvec[3], TexResult *texres)
|
|||
}
|
||||
else { /* sphere TEX_SPHERE */
|
||||
texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
|
||||
if (texres->tin < 0.0f)
|
||||
if (texres->tin < 0.0f) {
|
||||
texres->tin = 0.0f;
|
||||
if (tex->stype == TEX_HALO)
|
||||
}
|
||||
if (tex->stype == TEX_HALO) {
|
||||
texres->tin *= texres->tin; /* halo */
|
||||
}
|
||||
}
|
||||
|
||||
BRICONT;
|
||||
|
@ -244,8 +250,9 @@ static float tex_saw(float a)
|
|||
|
||||
int n = (int)(a / b);
|
||||
a -= n * b;
|
||||
if (a < 0)
|
||||
if (a < 0) {
|
||||
a += b;
|
||||
}
|
||||
return a / b;
|
||||
}
|
||||
|
||||
|
@ -274,8 +281,9 @@ static float wood_int(Tex *tex, float x, float y, float z)
|
|||
waveform[1] = tex_saw;
|
||||
waveform[2] = tex_tri;
|
||||
|
||||
if ((wf > TEX_TRI) || (wf < TEX_SIN))
|
||||
if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
|
||||
wf = 0; /* check to be sure noisebasis2 is initialized ahead of time */
|
||||
}
|
||||
|
||||
if (wt == TEX_BAND) {
|
||||
wi = waveform[wf]((x + y + z) * 10.0f);
|
||||
|
@ -329,8 +337,9 @@ static float marble_int(Tex *tex, float x, float y, float z)
|
|||
waveform[1] = tex_saw;
|
||||
waveform[2] = tex_tri;
|
||||
|
||||
if ((wf > TEX_TRI) || (wf < TEX_SIN))
|
||||
if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
|
||||
wf = 0; /* check to be sure noisebasis2 isn't initialized ahead of time */
|
||||
}
|
||||
|
||||
n = 5.0f * (x + y + z);
|
||||
|
||||
|
@ -469,8 +478,9 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
|
|||
|
||||
ofs = tex->turbul / 200.0f;
|
||||
|
||||
if (tex->stype)
|
||||
if (tex->stype) {
|
||||
ofs *= (b2 * b2);
|
||||
}
|
||||
nor[0] = BLI_gNoise(tex->noisesize,
|
||||
texvec[0] + ofs,
|
||||
texvec[1],
|
||||
|
@ -506,11 +516,13 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres)
|
|||
retval |= TEX_NOR;
|
||||
}
|
||||
|
||||
if (tex->stype == TEX_WALLOUT)
|
||||
if (tex->stype == TEX_WALLOUT) {
|
||||
texres->tin = 1.0f - texres->tin;
|
||||
}
|
||||
|
||||
if (texres->tin < 0.0f)
|
||||
if (texres->tin < 0.0f) {
|
||||
texres->tin = 0.0f;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -523,10 +535,12 @@ static float mg_mFractalOrfBmTex(Tex *tex, const float texvec[3], TexResult *tex
|
|||
int rv = TEX_INT;
|
||||
float (*mgravefunc)(float, float, float, float, float, float, int);
|
||||
|
||||
if (tex->stype == TEX_MFRACTAL)
|
||||
if (tex->stype == TEX_MFRACTAL) {
|
||||
mgravefunc = mg_MultiFractal;
|
||||
else
|
||||
}
|
||||
else {
|
||||
mgravefunc = mg_fBm;
|
||||
}
|
||||
|
||||
texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
|
||||
texvec[1],
|
||||
|
@ -576,10 +590,12 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, const float texvec[3], TexResult *
|
|||
int rv = TEX_INT;
|
||||
float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
|
||||
|
||||
if (tex->stype == TEX_RIDGEDMF)
|
||||
if (tex->stype == TEX_RIDGEDMF) {
|
||||
mgravefunc = mg_RidgedMultiFractal;
|
||||
else
|
||||
}
|
||||
else {
|
||||
mgravefunc = mg_HybridMultiFractal;
|
||||
}
|
||||
|
||||
texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
|
||||
texvec[1],
|
||||
|
@ -737,8 +753,9 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
|
|||
float aw3 = fabsf(tex->vn_w3);
|
||||
float aw4 = fabsf(tex->vn_w4);
|
||||
float sc = (aw1 + aw2 + aw3 + aw4);
|
||||
if (sc != 0.f)
|
||||
if (sc != 0.f) {
|
||||
sc = tex->ns_outscale / sc;
|
||||
}
|
||||
|
||||
voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
|
||||
texres->tin = sc * fabsf(tex->vn_w1 * da[0] + tex->vn_w2 * da[1] + tex->vn_w3 * da[2] +
|
||||
|
@ -764,12 +781,15 @@ static float voronoiTex(Tex *tex, const float texvec[3], TexResult *texres)
|
|||
texres->tb += aw4 * ca[2];
|
||||
if (tex->vn_coltype >= 2) {
|
||||
float t1 = (da[1] - da[0]) * 10;
|
||||
if (t1 > 1)
|
||||
if (t1 > 1) {
|
||||
t1 = 1;
|
||||
if (tex->vn_coltype == 3)
|
||||
}
|
||||
if (tex->vn_coltype == 3) {
|
||||
t1 *= texres->tin;
|
||||
else
|
||||
}
|
||||
else {
|
||||
t1 *= sc;
|
||||
}
|
||||
texres->tr *= t1;
|
||||
texres->tg *= t1;
|
||||
texres->tb *= t1;
|
||||
|
@ -895,10 +915,12 @@ static void do_2d_mapping(
|
|||
fx = (texvec[0] + 1.0f) / 2.0f;
|
||||
fy = (texvec[1] + 1.0f) / 2.0f;
|
||||
}
|
||||
else if (wrap == MTEX_TUBE)
|
||||
else if (wrap == MTEX_TUBE) {
|
||||
map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
|
||||
else if (wrap == MTEX_SPHERE)
|
||||
}
|
||||
else if (wrap == MTEX_SPHERE) {
|
||||
map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
|
||||
}
|
||||
else {
|
||||
cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
|
||||
}
|
||||
|
@ -908,29 +930,35 @@ static void do_2d_mapping(
|
|||
if (tex->xrepeat > 1) {
|
||||
float origf = fx *= tex->xrepeat;
|
||||
|
||||
if (fx > 1.0f)
|
||||
if (fx > 1.0f) {
|
||||
fx -= (int)(fx);
|
||||
else if (fx < 0.0f)
|
||||
}
|
||||
else if (fx < 0.0f) {
|
||||
fx += 1 - (int)(fx);
|
||||
}
|
||||
|
||||
if (tex->flag & TEX_REPEAT_XMIR) {
|
||||
int orig = (int)floor(origf);
|
||||
if (orig & 1)
|
||||
if (orig & 1) {
|
||||
fx = 1.0f - fx;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tex->yrepeat > 1) {
|
||||
float origf = fy *= tex->yrepeat;
|
||||
|
||||
if (fy > 1.0f)
|
||||
if (fy > 1.0f) {
|
||||
fy -= (int)(fy);
|
||||
else if (fy < 0.0f)
|
||||
}
|
||||
else if (fy < 0.0f) {
|
||||
fy += 1 - (int)(fy);
|
||||
}
|
||||
|
||||
if (tex->flag & TEX_REPEAT_YMIR) {
|
||||
int orig = (int)floor(origf);
|
||||
if (orig & 1)
|
||||
if (orig & 1) {
|
||||
fy = 1.0f - fy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -994,10 +1022,12 @@ static void do_2d_mapping(
|
|||
areaflag = 1;
|
||||
}
|
||||
else {
|
||||
if (wrap == MTEX_TUBE)
|
||||
if (wrap == MTEX_TUBE) {
|
||||
map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
|
||||
}
|
||||
dxt[0] /= 2.0f;
|
||||
dxt[1] /= 2.0f;
|
||||
dyt[0] /= 2.0f;
|
||||
|
@ -1049,15 +1079,18 @@ static void do_2d_mapping(
|
|||
|
||||
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
|
||||
if (tex->texfilter == TXF_BOX) {
|
||||
if (fx > 1.0f)
|
||||
if (fx > 1.0f) {
|
||||
fx -= (int)(fx);
|
||||
else if (fx < 0.0f)
|
||||
}
|
||||
else if (fx < 0.0f) {
|
||||
fx += 1 - (int)(fx);
|
||||
}
|
||||
|
||||
if (tex->flag & TEX_REPEAT_XMIR) {
|
||||
int orig = (int)floor(origf);
|
||||
if (orig & 1)
|
||||
if (orig & 1) {
|
||||
fx = 1.0f - fx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1071,20 +1104,24 @@ static void do_2d_mapping(
|
|||
|
||||
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
|
||||
if (tex->texfilter == TXF_BOX) {
|
||||
if (fy > 1.0f)
|
||||
if (fy > 1.0f) {
|
||||
fy -= (int)(fy);
|
||||
else if (fy < 0.0f)
|
||||
}
|
||||
else if (fy < 0.0f) {
|
||||
fy += 1 - (int)(fy);
|
||||
}
|
||||
|
||||
if (tex->flag & TEX_REPEAT_YMIR) {
|
||||
int orig = (int)floor(origf);
|
||||
if (orig & 1)
|
||||
if (orig & 1) {
|
||||
fy = 1.0f - fy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (max < tex->yrepeat)
|
||||
if (max < tex->yrepeat) {
|
||||
max = tex->yrepeat;
|
||||
}
|
||||
|
||||
dxt[1] *= tex->yrepeat;
|
||||
dyt[1] *= tex->yrepeat;
|
||||
|
@ -1175,11 +1212,13 @@ static int multitex(Tex *tex,
|
|||
retval = texnoise(tex, texres, thread);
|
||||
break;
|
||||
case TEX_IMAGE:
|
||||
if (osatex)
|
||||
if (osatex) {
|
||||
retval = imagewraposa(
|
||||
tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool, skip_load_image);
|
||||
else
|
||||
}
|
||||
else {
|
||||
retval = imagewrap(tex, tex->ima, NULL, texvec, texres, pool, skip_load_image);
|
||||
}
|
||||
if (tex->ima) {
|
||||
BKE_image_tag_time(tex->ima);
|
||||
}
|
||||
|
@ -1263,8 +1302,9 @@ static int multitex_nodes_intern(Tex *tex,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (mtex)
|
||||
if (mtex) {
|
||||
which_output = mtex->which_output;
|
||||
}
|
||||
|
||||
if (tex->type == TEX_IMAGE) {
|
||||
int rgbnor;
|
||||
|
@ -1490,18 +1530,24 @@ void texture_rgb_blend(
|
|||
fact *= facg;
|
||||
facm = 1.0f - fact;
|
||||
|
||||
if (out[0] < 0.5f)
|
||||
if (out[0] < 0.5f) {
|
||||
in[0] = out[0] * (facm + 2.0f * fact * tex[0]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
in[0] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[0])) * (1.0f - out[0]);
|
||||
if (out[1] < 0.5f)
|
||||
}
|
||||
if (out[1] < 0.5f) {
|
||||
in[1] = out[1] * (facm + 2.0f * fact * tex[1]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
in[1] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[1])) * (1.0f - out[1]);
|
||||
if (out[2] < 0.5f)
|
||||
}
|
||||
if (out[2] < 0.5f) {
|
||||
in[2] = out[2] * (facm + 2.0f * fact * tex[2]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
in[2] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[2])) * (1.0f - out[2]);
|
||||
}
|
||||
break;
|
||||
|
||||
case MTEX_SUB:
|
||||
|
@ -1518,12 +1564,15 @@ void texture_rgb_blend(
|
|||
fact *= facg;
|
||||
facm = 1.0f - fact;
|
||||
|
||||
if (tex[0] != 0.0f)
|
||||
if (tex[0] != 0.0f) {
|
||||
in[0] = facm * out[0] + fact * out[0] / tex[0];
|
||||
if (tex[1] != 0.0f)
|
||||
}
|
||||
if (tex[1] != 0.0f) {
|
||||
in[1] = facm * out[1] + fact * out[1] / tex[1];
|
||||
if (tex[2] != 0.0f)
|
||||
}
|
||||
if (tex[2] != 0.0f) {
|
||||
in[2] = facm * out[2] + fact * out[2] / tex[2];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1594,8 +1643,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
|
|||
|
||||
fact *= facg;
|
||||
facm = 1.0f - fact;
|
||||
if (flip)
|
||||
if (flip) {
|
||||
SWAP(float, fact, facm);
|
||||
}
|
||||
|
||||
switch (blendtype) {
|
||||
case MTEX_BLEND:
|
||||
|
@ -1614,10 +1664,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
|
|||
|
||||
case MTEX_OVERLAY:
|
||||
facm = 1.0f - facg;
|
||||
if (out < 0.5f)
|
||||
if (out < 0.5f) {
|
||||
in = out * (facm + 2.0f * fact * tex);
|
||||
else
|
||||
}
|
||||
else {
|
||||
in = 1.0f - (facm + 2.0f * fact * (1.0f - tex)) * (1.0f - out);
|
||||
}
|
||||
break;
|
||||
|
||||
case MTEX_SUB:
|
||||
|
@ -1628,8 +1680,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
|
|||
break;
|
||||
|
||||
case MTEX_DIV:
|
||||
if (tex != 0.0f)
|
||||
if (tex != 0.0f) {
|
||||
in = facm * out + fact * out / tex;
|
||||
}
|
||||
break;
|
||||
|
||||
case MTEX_DIFF:
|
||||
|
@ -1642,10 +1695,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
|
|||
|
||||
case MTEX_LIGHT:
|
||||
col = fact * tex;
|
||||
if (col > out)
|
||||
if (col > out) {
|
||||
in = col;
|
||||
else
|
||||
}
|
||||
else {
|
||||
in = out;
|
||||
}
|
||||
break;
|
||||
|
||||
case MTEX_SOFT_LIGHT:
|
||||
|
@ -1654,10 +1709,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
|
|||
break;
|
||||
|
||||
case MTEX_LIN_LIGHT:
|
||||
if (tex > 0.5f)
|
||||
if (tex > 0.5f) {
|
||||
in = out + fact * (2.0f * (tex - 0.5f));
|
||||
else
|
||||
}
|
||||
else {
|
||||
in = out + fact * (2.0f * tex - 1.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1684,25 +1741,32 @@ int externtex(const MTex *mtex,
|
|||
int rgb;
|
||||
|
||||
tex = mtex->tex;
|
||||
if (tex == NULL)
|
||||
if (tex == NULL) {
|
||||
return 0;
|
||||
}
|
||||
texr.nor = NULL;
|
||||
|
||||
/* placement */
|
||||
if (mtex->projx)
|
||||
if (mtex->projx) {
|
||||
texvec[0] = mtex->size[0] * (vec[mtex->projx - 1] + mtex->ofs[0]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
texvec[0] = mtex->size[0] * (mtex->ofs[0]);
|
||||
}
|
||||
|
||||
if (mtex->projy)
|
||||
if (mtex->projy) {
|
||||
texvec[1] = mtex->size[1] * (vec[mtex->projy - 1] + mtex->ofs[1]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
texvec[1] = mtex->size[1] * (mtex->ofs[1]);
|
||||
}
|
||||
|
||||
if (mtex->projz)
|
||||
if (mtex->projz) {
|
||||
texvec[2] = mtex->size[2] * (vec[mtex->projz - 1] + mtex->ofs[2]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
texvec[2] = mtex->size[2] * (mtex->ofs[2]);
|
||||
}
|
||||
|
||||
/* texture */
|
||||
if (tex->type == TEX_IMAGE) {
|
||||
|
|
|
@ -56,10 +56,12 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty)
|
|||
void zbuf_free_span(ZSpan *zspan)
|
||||
{
|
||||
if (zspan) {
|
||||
if (zspan->span1)
|
||||
if (zspan->span1) {
|
||||
MEM_freeN(zspan->span1);
|
||||
if (zspan->span2)
|
||||
}
|
||||
if (zspan->span2) {
|
||||
MEM_freeN(zspan->span2);
|
||||
}
|
||||
zspan->span1 = zspan->span2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -91,18 +93,22 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
|
|||
my0 = ceil(minv[1]);
|
||||
my2 = floor(maxv[1]);
|
||||
|
||||
if (my2 < 0 || my0 >= zspan->recty)
|
||||
if (my2 < 0 || my0 >= zspan->recty) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* clip top */
|
||||
if (my2 >= zspan->recty)
|
||||
if (my2 >= zspan->recty) {
|
||||
my2 = zspan->recty - 1;
|
||||
}
|
||||
/* clip bottom */
|
||||
if (my0 < 0)
|
||||
if (my0 < 0) {
|
||||
my0 = 0;
|
||||
}
|
||||
|
||||
if (my0 > my2)
|
||||
if (my0 > my2) {
|
||||
return;
|
||||
}
|
||||
/* if (my0>my2) should still fill in, that way we get spans that skip nicely */
|
||||
|
||||
xx1 = maxv[1] - minv[1];
|
||||
|
@ -136,10 +142,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
|
|||
if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
|
||||
zspan->maxp1 = maxv;
|
||||
}
|
||||
if (my0 < zspan->miny1)
|
||||
if (my0 < zspan->miny1) {
|
||||
zspan->miny1 = my0;
|
||||
if (my2 > zspan->maxy1)
|
||||
}
|
||||
if (my2 > zspan->maxy1) {
|
||||
zspan->maxy1 = my2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// printf("right span my0 %d my2 %d\n", my0, my2);
|
||||
|
@ -149,10 +157,12 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
|
|||
if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
|
||||
zspan->maxp2 = maxv;
|
||||
}
|
||||
if (my0 < zspan->miny2)
|
||||
if (my0 < zspan->miny2) {
|
||||
zspan->miny2 = my0;
|
||||
if (my2 > zspan->maxy2)
|
||||
}
|
||||
if (my2 > zspan->maxy2) {
|
||||
zspan->maxy2 = my2;
|
||||
}
|
||||
}
|
||||
|
||||
for (y = my2; y >= my0; y--, xs0 += dx0) {
|
||||
|
@ -189,15 +199,17 @@ void zspan_scanconvert(ZSpan *zspan,
|
|||
zbuf_add_to_span(zspan, v3, v1);
|
||||
|
||||
/* clipped */
|
||||
if (zspan->minp2 == NULL || zspan->maxp2 == NULL)
|
||||
if (zspan->minp2 == NULL || zspan->maxp2 == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
my0 = max_ii(zspan->miny1, zspan->miny2);
|
||||
my2 = min_ii(zspan->maxy1, zspan->maxy2);
|
||||
|
||||
// printf("my %d %d\n", my0, my2);
|
||||
if (my2 < my0)
|
||||
if (my2 < my0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* ZBUF DX DY, in floats still */
|
||||
x1 = v1[0] - v2[0];
|
||||
|
@ -212,8 +224,9 @@ void zspan_scanconvert(ZSpan *zspan,
|
|||
y0 = z1 * x2 - x1 * z2;
|
||||
z0 = x1 * y2 - y1 * x2;
|
||||
|
||||
if (z0 == 0.0f)
|
||||
if (z0 == 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + 1.0f;
|
||||
uxd = -(double)x0 / (double)z0;
|
||||
|
@ -241,10 +254,12 @@ void zspan_scanconvert(ZSpan *zspan,
|
|||
sn2 = floor(max_ff(*span1, *span2));
|
||||
sn1++;
|
||||
|
||||
if (sn2 >= rectx)
|
||||
if (sn2 >= rectx) {
|
||||
sn2 = rectx - 1;
|
||||
if (sn1 < 0)
|
||||
}
|
||||
if (sn1 < 0) {
|
||||
sn1 = 0;
|
||||
}
|
||||
|
||||
u = (((double)sn1 * uxd) + uy0) - (i * uyd);
|
||||
v = (((double)sn1 * vxd) + vy0) - (i * vyd);
|
||||
|
|
Loading…
Reference in New Issue