svn merge ^/trunk/blender -r50080:50089

This commit is contained in:
Campbell Barton
2012-08-21 15:16:53 +00:00
28 changed files with 177 additions and 68 deletions

View File

@@ -70,21 +70,28 @@ void curvemap_sethandle(struct CurveMap *cuma, int type);
void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles);
void curvemapping_changed_all(struct CurveMapping *cumap);
/* call before _all_ evaluation functions */
void curvemapping_initialize(struct CurveMapping *cumap);
/* keep these (const CurveMap) - to help with thread safety */
/* single curve, no table check */
float curvemap_evaluateF(struct CurveMap *cuma, float value);
float curvemap_evaluateF(const struct CurveMap *cuma, float value);
/* single curve, with table check */
float curvemapping_evaluateF(struct CurveMapping *cumap, int cur, float value);
void curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluate_premulRGB(struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]);
void curvemapping_evaluate_premulRGBF_ex(struct CurveMapping *cumap, float vecout[3], const float vecin[3],
float curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value);
void curvemapping_evaluate3F(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluateRGBF(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]);
void curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, float vecout[3], const float vecin[3],
const float black[3], const float bwmul[3]);
void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
int curvemapping_RGBA_does_something(const struct CurveMapping *cumap);
void curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size);
/* non-const, these modify the curve */
void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf);
void curvemapping_premultiply(struct CurveMapping *cumap, int restore);
int curvemapping_RGBA_does_something(struct CurveMapping *cumap);
void curvemapping_initialize(struct CurveMapping *cumap);
void curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size);
void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management);
void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management);
void scopes_free(struct Scopes *scopes);

View File

@@ -1253,7 +1253,9 @@ float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len)
if (p >= len) return 0;
else p = p / len;
curvemapping_initialize(br->curve);
p = curvemapping_evaluateF(br->curve, 0, p);
if (p < 0.0f) p = 0.0f;
else if (p > 1.0f) p = 1.0f;
return p;
@@ -1267,6 +1269,7 @@ float BKE_brush_curve_strength(Brush *br, float p, const float len)
else
p = p / len;
curvemapping_initialize(br->curve);
return curvemapping_evaluateF(br->curve, 0, p);
}

View File

@@ -151,13 +151,8 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3],
int a;
for (a = 0; a < 3; a++) {
const float delta = white[a] - black[a];
if (delta != 0.0f) {
r_bwmul[a] = 1.0f / delta;
}
else {
r_bwmul[a] = 0.0f;
}
const float delta = maxf(white[a] - black[a], 1e-5f);
r_bwmul[a] = 1.0f / delta;
}
}
@@ -446,7 +441,7 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
/* in X, out Y.
* X is presumed to be outside first or last */
static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2])
static float curvemap_calc_extend(const CurveMap *cuma, float x, const float first[2], const float last[2])
{
if (x <= first[0]) {
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
@@ -745,7 +740,7 @@ void curvemapping_changed_all(CurveMapping *cumap)
}
/* table should be verified */
float curvemap_evaluateF(CurveMap *cuma, float value)
float curvemap_evaluateF(const CurveMap *cuma, float value)
{
float fi;
int i;
@@ -767,33 +762,26 @@ float curvemap_evaluateF(CurveMap *cuma, float value)
}
/* works with curve 'cur' */
float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value)
float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
{
CurveMap *cuma = cumap->cm + cur;
/* allocate or bail out */
if (cuma->table == NULL) {
curvemap_make_table(cuma, &cumap->clipr);
if (cuma->table == NULL)
return 1.0f - value;
}
const CurveMap *cuma = cumap->cm + cur;
return curvemap_evaluateF(cuma, value);
}
/* vector case */
void curvemapping_evaluate3F(CurveMapping *cumap, float vecout[3], const float vecin[3])
void curvemapping_evaluate3F(const CurveMapping *cumap, float vecout[3], const float vecin[3])
{
vecout[0] = curvemapping_evaluateF(cumap, 0, vecin[0]);
vecout[1] = curvemapping_evaluateF(cumap, 1, vecin[1]);
vecout[2] = curvemapping_evaluateF(cumap, 2, vecin[2]);
vecout[0] = curvemap_evaluateF(&cumap->cm[0], vecin[0]);
vecout[1] = curvemap_evaluateF(&cumap->cm[1], vecin[1]);
vecout[2] = curvemap_evaluateF(&cumap->cm[2], vecin[2]);
}
/* RGB case, no black/white points, no premult */
void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])
void curvemapping_evaluateRGBF(const CurveMapping *cumap, float vecout[3], const float vecin[3])
{
vecout[0] = curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0]));
vecout[1] = curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1]));
vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2]));
vecout[0] = curvemap_evaluateF(&cumap->cm[0], curvemap_evaluateF(&cumap->cm[3], vecin[0]));
vecout[1] = curvemap_evaluateF(&cumap->cm[1], curvemap_evaluateF(&cumap->cm[3], vecin[1]));
vecout[2] = curvemap_evaluateF(&cumap->cm[2], curvemap_evaluateF(&cumap->cm[3], vecin[2]));
}
/** same as #curvemapping_evaluate_premulRGBF
@@ -805,7 +793,7 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float
* \param black Use instead of cumap->black
* \param bwmul Use instead of cumap->bwmul
*/
void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3],
void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, float vecout[3], const float vecin[3],
const float black[3], const float bwmul[3])
{
vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - black[0]) * bwmul[0]);
@@ -814,7 +802,7 @@ void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], c
}
/* RGB with black/white points and premult. tables are checked */
void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])
void curvemapping_evaluate_premulRGBF(const CurveMapping *cumap, float vecout[3], const float vecin[3])
{
vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - cumap->black[0]) * cumap->bwmul[0]);
vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - cumap->black[1]) * cumap->bwmul[1]);
@@ -822,7 +810,7 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], cons
}
/* same as above, byte version */
void curvemapping_evaluate_premulRGB(CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3])
void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3])
{
float vecin[3], vecout[3];
@@ -895,7 +883,7 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
curvemapping_premultiply(cumap, 1);
}
int curvemapping_RGBA_does_something(CurveMapping *cumap)
int curvemapping_RGBA_does_something(const CurveMapping *cumap)
{
int a;
@@ -931,13 +919,12 @@ void curvemapping_initialize(CurveMapping *cumap)
}
}
void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size)
void curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size)
{
int a;
*size = CM_TABLE + 1;
*array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping");
curvemapping_initialize(cumap);
for (a = 0; a < *size; a++) {
if (cumap->cm[0].table)

View File

@@ -128,8 +128,9 @@ World *BKE_world_copy(World *wrld)
}
}
if (wrld->nodetree)
if (wrld->nodetree) {
wrldn->nodetree = ntreeCopyTree(wrld->nodetree);
}
if (wrld->preview)
wrldn->preview = BKE_previewimg_copy(wrld->preview);

View File

@@ -380,10 +380,18 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
/* this should always be wire, so this is mainly a speedup to avoid map lookup */
if (BM_edge_is_wire(e) && BMO_slot_map_contains(bm, op, "exclude", e)) {
BMVert *v1 = e->v1, *v2 = e->v2;
/* The original edge was excluded,
* this would result in a standalone wire edge - see [#30399] */
BM_edge_kill(bm, e);
/* kill standalone vertices from this edge - see [#32341] */
if (!v1->e)
BM_vert_kill(bm, v1);
if (!v2->e)
BM_vert_kill(bm, v1);
continue;
}

View File

@@ -53,6 +53,7 @@ void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
fac = (context->getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1);
}
curvemapping_initialize((CurveMapping *)node->storage);
fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
operation->setValue(CLAMPIS(fac, 0.0f, 1.0f));
graph->addOperation(operation);

View File

@@ -98,11 +98,11 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS
void ColorCurveOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
this->m_inputFacProgram = NULL;
this->m_inputImageProgram = NULL;
this->m_inputBlackProgram = NULL;
this->m_inputWhiteProgram = NULL;
curvemapping_premultiply(this->m_curveMapping, 1);
}
@@ -154,7 +154,7 @@ void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, fl
void ConstantLevelColorCurveOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
this->m_inputFacProgram = NULL;
this->m_inputImageProgram = NULL;
curvemapping_premultiply(this->m_curveMapping, 1);
}

View File

@@ -38,3 +38,17 @@ void CurveBaseOperation::initExecution()
{
curvemapping_initialize(this->m_curveMapping);
}
void CurveBaseOperation::deinitExecution()
{
curvemapping_free(this->m_curveMapping);
this->m_curveMapping = NULL;
}
void CurveBaseOperation::setCurveMapping(CurveMapping *mapping)
{
/* duplicate the curve to avoid glitches while drawing, see bug [#32374] */
if (this->m_curveMapping) {
curvemapping_free(this->m_curveMapping);
}
this->m_curveMapping = curvemapping_copy(mapping);
}

View File

@@ -38,7 +38,8 @@ public:
* Initialize the execution
*/
void initExecution();
void deinitExecution();
void setCurveMapping(CurveMapping *mapping) { this->m_curveMapping = mapping; }
void setCurveMapping(CurveMapping *mapping);
};
#endif

View File

@@ -74,5 +74,6 @@ void HueSaturationValueCorrectOperation::executePixel(float output[4], float x,
void HueSaturationValueCorrectOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
this->m_inputProgram = NULL;
}

View File

@@ -56,5 +56,6 @@ void VectorCurveOperation::executePixel(float output[4], float x, float y, Pixel
void VectorCurveOperation::deinitExecution()
{
CurveBaseOperation::deinitExecution();
this->m_inputProgram = NULL;
}

View File

@@ -1355,8 +1355,14 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
rcti scissor_new;
int a;
cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin);
cuma = cumap->cm + cumap->cur;
if (but->editcumap) {
cumap = but->editcumap;
}
else {
cumap = (CurveMapping *)but->poin;
}
cuma = &cumap->cm[cumap->cur];
/* need scissor test, curve can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
@@ -1485,8 +1491,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
cmp = cuma->table;
/* first point */
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0)
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
glVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy));
}
else {
fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
@@ -1498,8 +1505,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
glVertex2f(fx, fy);
}
/* last point */
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0)
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
glVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy));
}
else {
fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);

View File

@@ -2122,23 +2122,49 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(ob);
BMOperator bmop;
BMIter iter;
BMVert *eve = NULL, *svert = NULL, *evert = NULL;
BMEditSelection *sv, *ev;
/* get the type from RNA */
int type = RNA_enum_get(op->ptr, "type");
/* first try to find vertices in edit selection */
sv = em->bm->selected.last;
if (sv != NULL)
if (sv != NULL) {
ev = sv->prev;
else return OPERATOR_CANCELLED;
if (ev == NULL)
return OPERATOR_CANCELLED;
if ((sv->htype != BM_VERT) || (ev->htype != BM_VERT))
if (ev && (sv->htype == BM_VERT) && (ev->htype == BM_VERT)) {
svert = (BMVert *)sv->ele;
evert = (BMVert *)ev->ele;
}
}
/* if those are not found, because vertices where selected by e.g.
border or circle select, find two selected vertices */
if (svert == NULL) {
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
continue;
if (svert == NULL) svert = eve;
else if (evert == NULL) evert = eve;
else {
/* more than two vertices are selected,
show warning message and cancel operator */
svert = evert = NULL;
break;
}
}
}
if (svert == NULL || evert == NULL) {
BKE_report(op->reports, RPT_WARNING, "Path Selection requires that two vertices be selected");
return OPERATOR_CANCELLED;
}
/* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", sv->ele, ev->ele, type);
EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", svert, evert, type);
/* execute the operator */
BMO_op_exec(em->bm, &bmop);
@@ -2932,12 +2958,12 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BMe
BMIter iter;
int result = FALSE;
BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE);
while ((f_cmp = BM_iter_at_index(bm_old, BM_FACES_OF_MESH, NULL, 0))) {
const short mat_nr = f_cmp->mat_nr;
int tot = 0;
BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE);
BM_ITER_MESH (f, &iter, bm_old, BM_FACES_OF_MESH) {
if (f->mat_nr == mat_nr) {
BMLoop *l_iter;

View File

@@ -427,6 +427,7 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode
float *array;
int size;
curvemapping_initialize(lamp->curfalloff);
curvemapping_table_RGBA(lamp->curfalloff, &array, &size);
GPU_link(mat, "lamp_falloff_curve", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_texture(size, array), *dist, &visifac);
}

View File

@@ -465,6 +465,12 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain)
}
}
/* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */
float rna_CurveMap_evaluateF(struct CurveMap *cuma, float value)
{
return curvemap_evaluateF(cuma, value);
}
#else
static void rna_def_curvemappoint(BlenderRNA *brna)
@@ -547,7 +553,7 @@ static void rna_def_curvemap(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Points", "");
rna_def_curvemap_points_api(brna, prop);
func = RNA_def_function(srna, "evaluate", "curvemap_evaluateF");
func = RNA_def_function(srna, "evaluate", "rna_CurveMap_evaluateF");
RNA_def_function_ui_description(func, "Evaluate curve at given location");
parm = RNA_def_float(func, "position", 0.0f, -FLT_MAX, FLT_MAX, "Position", "Position to evaluate curve at", -FLT_MAX, FLT_MAX);
RNA_def_property_flag(parm, PROP_REQUIRED);

View File

@@ -195,6 +195,10 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */
wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
if (wmd->curfalloff) {
curvemapping_initialize(wmd->curfalloff);
}
invert_m4_m4(obinv, ob->obmat);
mult_m4_m4m4(mat_from, obinv, wmd->object_from->obmat);

View File

@@ -73,6 +73,10 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm
return;
}
if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) {
curvemapping_initialize(cmap);
}
/* Map each weight (vertex) to its new value, accordingly to the chosen mode. */
for (i = 0; i < num; ++i) {
float fac = new_w[i];

View File

@@ -95,7 +95,9 @@ static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)
for (sock= node->outputs.first; sock; sock= sock->next) {
if (sock->cache) {
#ifdef WITH_COMPOSITOR_LEGACY
free_compbuf(sock->cache);
#endif
sock->cache= NULL;
}
}
@@ -159,8 +161,9 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree)
for (sock= node->outputs.first; sock; sock= sock->next) {
sock->new_sock->cache= sock->cache;
#ifdef WITH_COMPOSITOR_LEGACY
compbuf_set_node(sock->new_sock->cache, node->new_node);
#endif
sock->cache= NULL;
sock->new_sock->new_sock= sock;
}
@@ -236,7 +239,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
for (lsock= lnode->outputs.first; lsock; lsock= lsock->next) {
if (ntreeOutputExists(lnode->new_node, lsock->new_sock)) {
lsock->new_sock->cache= lsock->cache;
#ifdef WITH_COMPOSITOR_LEGACY
compbuf_set_node(lsock->new_sock->cache, lnode->new_node);
#endif
lsock->cache= NULL;
lsock->new_sock= NULL;
}

View File

@@ -29,9 +29,10 @@
* \ingroup nodes
*/
#include "node_composite_util.h"
#ifdef WITH_COMPOSITOR_LEGACY
#include <limits.h>
CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc)
@@ -1405,3 +1406,4 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
#undef YVV
}
#endif /* WITH_COMPOSITOR_LEGACY */

View File

@@ -86,6 +86,9 @@
/* only for forward declarations */
#include "NOD_composite.h"
#define CMP_SCALE_MAX 12000
#ifdef WITH_COMPOSITOR_LEGACY
/* *************************** operations support *************************** */
@@ -198,9 +201,9 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy);
/* transformations */
#define CMP_SCALE_MAX 12000
CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, float scale, int filter_type);
float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc);
#endif
#endif /* WITH_COMPOSITOR_LEGACY */

View File

@@ -30,7 +30,6 @@
* \ingroup cmpnodes
*/
#include "DNA_node_types.h"
#include "BKE_node.h"
@@ -184,7 +183,9 @@ static void group_free_internal(bNodeTreeExec *gexec)
for (i=0, ns=gexec->stack; i < gexec->stacksize; ++i, ++ns) {
if (!ns->external && !ns->is_copy) {
if (ns->data) {
#ifdef WITH_COMPOSITOR_LEGACY
free_compbuf(ns->data);
#endif
ns->data = NULL;
}
}
@@ -231,6 +232,7 @@ void register_node_type_cmp_group(bNodeTreeType *ttype)
nodeRegisterType(ttype, &ntype);
}
#ifdef WITH_COMPOSITOR_LEGACY
/**** FOR LOOP ****/
@@ -377,3 +379,5 @@ void register_node_type_cmp_whileloop(bNodeTreeType *ttype)
nodeRegisterType(ttype, &ntype);
}
#endif
#endif /* WITH_COMPOSITOR_LEGACY */

View File

@@ -52,7 +52,9 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack *
if (node->custom1 < node->custom2)
fac= (rd->cfra - node->custom1)/(float)(node->custom2-node->custom1);
fac= curvemapping_evaluateF(node->storage, 0, fac);
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f);
}
@@ -100,7 +102,8 @@ static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeS
{
/* stack order input: vec */
/* stack order output: vec */
curvemapping_initialize(node->storage);
curvemapping_evaluate_premulRGBF(node->storage, out[0]->vec, in[0]->vec);
}
@@ -146,13 +149,15 @@ static bNodeSocketTemplate cmp_node_curve_rgb_out[]= {
static void do_curves(bNode *node, float *out, float *in)
{
curvemapping_initialize(node->storage);
curvemapping_evaluate_premulRGBF(node->storage, out, in);
out[3]= in[3];
}
static void do_curves_fac(bNode *node, float *out, float *in, float *fac)
{
curvemapping_initialize(node->storage);
if (*fac >= 1.0f)
curvemapping_evaluate_premulRGBF(node->storage, out, in);
else if (*fac <= 0.0f) {
@@ -176,6 +181,8 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS
if (out[0]->hasoutput==0)
return;
curvemapping_initialize(node->storage);
/* input no image? then only color operation */
if (in[1]->data==NULL) {
curvemapping_evaluateRGBF(node->storage, out[0]->vec, in[1]->vec);

View File

@@ -51,6 +51,8 @@ static void do_huecorrect(bNode *node, float *out, float *in)
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
curvemapping_initialize(node->storage);
/* adjust hue, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
hsv[0] += f-0.5f;
@@ -79,6 +81,8 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac)
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
curvemapping_initialize(node->storage);
/* adjust hue, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
hsv[0] += f-0.5f;
@@ -118,7 +122,7 @@ static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNode
out[0]->data = pass_on_compbuf(cbuf);
return;
}
/* input no image? then only color operation */
if (in[1]->data==NULL) {
do_huecorrect_fac(node, out[0]->vec, in[1]->vec, in[0]->vec);

View File

@@ -65,6 +65,7 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, bNode *node, GPUNodeStack *in,
float *array;
int size;
curvemapping_initialize(node->storage);
curvemapping_table_RGBA(node->storage, &array, &size);
return GPU_stack_link(mat, "curves_vec", in, out, GPU_texture(size, array));
}
@@ -120,6 +121,8 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in,
{
float *array;
int size;
curvemapping_initialize(node->storage);
curvemapping_table_RGBA(node->storage, &array, &size);
return GPU_stack_link(mat, "curves_rgb", in, out, GPU_texture(size, array));
}

View File

@@ -49,6 +49,7 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNU
if (node->custom1 < node->custom2)
fac = (p->cfra - node->custom1)/(float)(node->custom2-node->custom1);
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
out[0] = CLAMPIS(fac, 0.0f, 1.0f);
}

View File

@@ -3824,6 +3824,11 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
lar->ld2= la->att2;
lar->curfalloff = curvemapping_copy(la->curfalloff);
if (lar->curfalloff) {
/* so threads don't conflict on init */
curvemapping_initialize(lar->curfalloff);
}
if (lar->type==LA_SPOT) {
normalize_v3(lar->imat[0]);

View File

@@ -379,6 +379,7 @@ static void accum_density(void *userdata, int index, float squared_dist)
}
if (pdr->density_curve && dist != 0.0f) {
curvemapping_initialize(pdr->density_curve);
density = curvemapping_evaluateF(pdr->density_curve, 0, density/dist)*dist;
}

View File

@@ -1192,6 +1192,7 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d
visifac*= lar->distkw/(lar->distkw+lar->ld2*dist[0]*dist[0]);
break;
case LA_FALLOFF_CURVE:
/* curvemapping_initialize is called from #add_render_lamp */
visifac = curvemapping_evaluateF(lar->curfalloff, 0, dist[0]/lar->dist);
break;
}