misc nodes & editors: floats were being implicitly promoted to doubles, adjust to use floats.
+ minor update to demo_mode
This commit is contained in:
@@ -243,7 +243,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
|
||||
int iNrActiveGroups = 0, index = 0;
|
||||
const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext);
|
||||
tbool bRes = TFALSE;
|
||||
const float fThresCos = (const float) cos((fAngularThreshold*M_PI)/180);
|
||||
const float fThresCos = (const float) cos((fAngularThreshold*(float)M_PI)/180.0f);
|
||||
|
||||
// verify all call-backs have been set
|
||||
if( pContext->m_pInterface->m_getNumFaces==NULL ||
|
||||
|
@@ -182,16 +182,16 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3
|
||||
t2= cotan_weight(v2, v3, v1);
|
||||
t3= cotan_weight(v3, v1, v2);
|
||||
|
||||
if(RAD2DEG(angle_v3v3v3(v2, v1, v3)) > 90) obtuse= 1;
|
||||
else if(RAD2DEG(angle_v3v3v3(v1, v2, v3)) > 90) obtuse= 2;
|
||||
else if(RAD2DEG(angle_v3v3v3(v1, v3, v2)) > 90) obtuse= 3;
|
||||
if(RAD2DEGF(angle_v3v3v3(v2, v1, v3)) > 90) obtuse= 1;
|
||||
else if(RAD2DEGF(angle_v3v3v3(v1, v2, v3)) > 90) obtuse= 2;
|
||||
else if(RAD2DEGF(angle_v3v3v3(v1, v3, v2)) > 90) obtuse= 3;
|
||||
|
||||
if (obtuse > 0) {
|
||||
area= area_tri_v3(v1, v2, v3);
|
||||
|
||||
varea[i1] += (obtuse == 1)? area: area*0.5;
|
||||
varea[i2] += (obtuse == 2)? area: area*0.5;
|
||||
varea[i3] += (obtuse == 3)? area: area*0.5;
|
||||
varea[i1] += (obtuse == 1)? area: area*0.5f;
|
||||
varea[i2] += (obtuse == 2)? area: area*0.5f;
|
||||
varea[i3] += (obtuse == 3)? area: area*0.5f;
|
||||
}
|
||||
else {
|
||||
len1= len_v3v3(v2, v3);
|
||||
@@ -492,7 +492,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
|
||||
|
||||
sub_v3_v3v3(data.vec, end, data.start);
|
||||
madd_v3_v3v3fl(data.start, data.start, data.vec, 1e-5);
|
||||
mul_v3_fl(data.vec, 1.0f - 2e-5);
|
||||
mul_v3_fl(data.vec, 1.0f - 2e-5f);
|
||||
|
||||
/* pass normalized vec + distance to bvh */
|
||||
hit.index = -1;
|
||||
@@ -1041,9 +1041,9 @@ void rigid_deform_end(int cancel)
|
||||
#define MESHDEFORM_TAG_INTERIOR 2
|
||||
#define MESHDEFORM_TAG_EXTERIOR 3
|
||||
|
||||
#define MESHDEFORM_LEN_THRESHOLD 1e-6
|
||||
#define MESHDEFORM_LEN_THRESHOLD 1e-6f
|
||||
|
||||
#define MESHDEFORM_MIN_INFLUENCE 0.0005
|
||||
#define MESHDEFORM_MIN_INFLUENCE 0.0005f
|
||||
|
||||
static int MESHDEFORM_OFFSET[7][3] =
|
||||
{{0,0,0}, {1,0,0}, {-1,0,0}, {0,1,0}, {0,-1,0}, {0,0,1}, {0,0,-1}};
|
||||
@@ -1146,7 +1146,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
|
||||
isectco[1]= (1.0f - u - v)*vert0[1] + u*vert1[1] + v*vert2[1];
|
||||
isectco[2]= (1.0f - u - v)*vert0[2] + u*vert1[2] + v*vert2[2];
|
||||
|
||||
uvw[0]= 1.0 - u - v;
|
||||
uvw[0]= 1.0f - u - v;
|
||||
uvw[1]= u;
|
||||
uvw[2]= v;
|
||||
|
||||
|
@@ -430,7 +430,7 @@ static int key_test_depth(PEData *data, float co[3])
|
||||
}
|
||||
#endif
|
||||
|
||||
if((float)uz - 0.00001 > depth)
|
||||
if((float)uz - 0.00001f > depth)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
@@ -3246,7 +3246,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
|
||||
if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){
|
||||
if(cur_d<*min_d){
|
||||
*min_d=cur_d;
|
||||
min_w[0]= 1.0 - cur_uv[0] - cur_uv[1];
|
||||
min_w[0]= 1.0f - cur_uv[0] - cur_uv[1];
|
||||
min_w[1]= cur_uv[0];
|
||||
min_w[2]= cur_uv[1];
|
||||
min_w[3]= 0.0f;
|
||||
@@ -3260,7 +3260,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa
|
||||
if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){
|
||||
if(cur_d<*min_d){
|
||||
*min_d=cur_d;
|
||||
min_w[0]= 1.0 - cur_uv[0] - cur_uv[1];
|
||||
min_w[0]= 1.0f - cur_uv[0] - cur_uv[1];
|
||||
min_w[1]= 0.0f;
|
||||
min_w[2]= cur_uv[0];
|
||||
min_w[3]= cur_uv[1];
|
||||
|
@@ -147,12 +147,12 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
|
||||
float *rf= rectf;
|
||||
float srgb[3];
|
||||
char *rc= rectc;
|
||||
const float dither = ibuf->dither / 255.0;
|
||||
const float dither = ibuf->dither / 255.0f;
|
||||
|
||||
/* XXX temp. because crop offset */
|
||||
if( rectc >= (char *)(ibuf->rect)) {
|
||||
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
|
||||
const float d = (BLI_frand()-0.5)*dither;
|
||||
const float d = (BLI_frand()-0.5f)*dither;
|
||||
srgb[0]= d + linearrgb_to_srgb(rf[0]);
|
||||
srgb[1]= d + linearrgb_to_srgb(rf[1]);
|
||||
srgb[2]= d + linearrgb_to_srgb(rf[2]);
|
||||
@@ -176,7 +176,7 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
|
||||
/* XXX temp. because crop offset */
|
||||
if( rectc >= (char *)(ibuf->rect)) {
|
||||
for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
|
||||
const float d = (BLI_frand()-0.5)*dither;
|
||||
const float d = (BLI_frand()-0.5f)*dither;
|
||||
|
||||
rgb[0] = d + rf[0];
|
||||
rgb[1] = d + rf[1];
|
||||
|
@@ -2766,7 +2766,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e
|
||||
else sync= (scene->flag & SCE_FRAME_DROP);
|
||||
|
||||
if((scene->audio.flag & AUDIO_SYNC) && !(sad->flag & ANIMPLAY_FLAG_REVERSE) && finite(time = sound_sync_scene(scene)))
|
||||
scene->r.cfra = time * FPS + 0.5;
|
||||
scene->r.cfra = (double)time * FPS + 0.5;
|
||||
else
|
||||
{
|
||||
if (sync) {
|
||||
|
@@ -322,11 +322,11 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
|
||||
* inactive regions, so use this for now. --matt
|
||||
*/
|
||||
|
||||
#define INFO_TIMEOUT 5.0
|
||||
#define INFO_COLOR_TIMEOUT 3.0
|
||||
#define ERROR_TIMEOUT 10.0
|
||||
#define ERROR_COLOR_TIMEOUT 6.0
|
||||
#define COLLAPSE_TIMEOUT 0.25
|
||||
#define INFO_TIMEOUT 5.0f
|
||||
#define INFO_COLOR_TIMEOUT 3.0f
|
||||
#define ERROR_TIMEOUT 10.0f
|
||||
#define ERROR_COLOR_TIMEOUT 6.0f
|
||||
#define COLLAPSE_TIMEOUT 0.25f
|
||||
static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
@@ -353,7 +353,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm
|
||||
color_timeout = (report->type & RPT_ERROR_ALL)?ERROR_COLOR_TIMEOUT:INFO_COLOR_TIMEOUT;
|
||||
|
||||
/* clear the report display after timeout */
|
||||
if (reports->reporttimer->duration > timeout) {
|
||||
if ((float)reports->reporttimer->duration > timeout) {
|
||||
WM_event_remove_timer(wm, NULL, reports->reporttimer);
|
||||
reports->reporttimer = NULL;
|
||||
|
||||
@@ -381,8 +381,8 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm
|
||||
rti->widthfac=1.0;
|
||||
}
|
||||
|
||||
progress = reports->reporttimer->duration / timeout;
|
||||
color_progress = reports->reporttimer->duration / color_timeout;
|
||||
progress = (float)reports->reporttimer->duration / timeout;
|
||||
color_progress = (float)reports->reporttimer->duration / color_timeout;
|
||||
|
||||
/* save us from too many draws */
|
||||
if(color_progress <= 1.0f) {
|
||||
|
@@ -1175,7 +1175,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
|
||||
fx = (bufx > 0.0f ? ((float)mx - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
|
||||
fy = (bufy > 0.0f ? ((float)my - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
|
||||
|
||||
if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) {
|
||||
if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) {
|
||||
float *fp;
|
||||
char *cp;
|
||||
int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y);
|
||||
|
@@ -52,12 +52,12 @@ static bNodeSocketType sh_node_hue_sat_out[]= {
|
||||
/* note: it would be possible to use CMP version for both nodes */
|
||||
static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float *hue, float *sat, float *val, float *in, float *fac)
|
||||
{
|
||||
if(*fac!=0.0f && (*hue!=0.5f || *sat!=1.0 || *val!=1.0)) {
|
||||
if(*fac!=0.0f && (*hue!=0.5f || *sat!=1.0f || *val!=1.0f)) {
|
||||
float col[3], hsv[3], mfac= 1.0f - *fac;
|
||||
|
||||
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
|
||||
hsv[0]+= (*hue - 0.5f);
|
||||
if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
|
||||
if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f;
|
||||
hsv[1]*= *sat;
|
||||
hsv[2]*= *val;
|
||||
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
|
||||
|
@@ -59,7 +59,7 @@ bNodeStack **out)
|
||||
|
||||
/* if fac, blend result against original input */
|
||||
if (in[0]->vec[0] < 1.0f) {
|
||||
facm = 1.0 - in[0]->vec[0];
|
||||
facm = 1.0f - in[0]->vec[0];
|
||||
|
||||
col[0] = in[0]->vec[0]*col[0] + (facm*in[1]->vec[0]);
|
||||
col[1] = in[0]->vec[0]*col[1] + (facm*in[1]->vec[1]);
|
||||
|
@@ -53,9 +53,9 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
|
||||
float sz = tex_input_value(in[2], p, thread);
|
||||
|
||||
/* 0.00001 because of unit sized stuff */
|
||||
int xi = (int)fabs(floor(0.00001 + x / sz));
|
||||
int yi = (int)fabs(floor(0.00001 + y / sz));
|
||||
int zi = (int)fabs(floor(0.00001 + z / sz));
|
||||
int xi = (int)fabs(floor(0.00001f + x / sz));
|
||||
int yi = (int)fabs(floor(0.00001f + y / sz));
|
||||
int zi = (int)fabs(floor(0.00001f + z / sz));
|
||||
|
||||
if( (xi % 2 == yi % 2) == (zi % 2) ) {
|
||||
tex_input_rgba(out, in[0], p, thread);
|
||||
|
@@ -54,11 +54,11 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
|
||||
|
||||
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
|
||||
hsv[0]+= (hue - 0.5f);
|
||||
if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0;
|
||||
if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f;
|
||||
hsv[1]*= sat;
|
||||
if(hsv[1]>1.0) hsv[1]= 1.0; else if(hsv[1]<0.0) hsv[1]= 0.0;
|
||||
if(hsv[1]>1.0f) hsv[1]= 1.0f; else if(hsv[1]<0.0f) hsv[1]= 0.0f;
|
||||
hsv[2]*= val;
|
||||
if(hsv[2]>1.0) hsv[2]= 1.0; else if(hsv[2]<0.0) hsv[2]= 0.0;
|
||||
if(hsv[2]>1.0f) hsv[2]= 1.0f; else if(hsv[2]<0.0f) hsv[2]= 0.0f;
|
||||
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
|
||||
|
||||
out[0]= mfac*in[0] + fac*col[0];
|
||||
|
@@ -116,8 +116,8 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
|
||||
out[0]= pow(in0, in1);
|
||||
} else {
|
||||
float y_mod_1 = fmod(in1, 1);
|
||||
if (y_mod_1 > 0.999 || y_mod_1 < 0.001) {
|
||||
*out = pow(in0, floor(in1 + 0.5));
|
||||
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
|
||||
*out = pow(in0, floor(in1 + 0.5f));
|
||||
} else {
|
||||
*out = 0.0;
|
||||
}
|
||||
|
@@ -53,8 +53,8 @@ static void rotate(float new_co[3], float a, float ax[3], float co[3])
|
||||
float perp[3];
|
||||
float cp[3];
|
||||
|
||||
float cos_a = cos(a * 2 * M_PI);
|
||||
float sin_a = sin(a * 2 * M_PI);
|
||||
float cos_a = cos(a * (float)(2*M_PI));
|
||||
float sin_a = sin(a * (float)(2*M_PI));
|
||||
|
||||
// x' = xcosa + n(n.x)(1-cosa) + (x*n)sina
|
||||
|
||||
|
@@ -552,7 +552,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < self->size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
|
||||
return PyFloat_FromDouble(dot);
|
||||
@@ -591,8 +591,8 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
return NULL;
|
||||
|
||||
for(x = 0; x < size; x++) {
|
||||
test_v1 += self->vec[x] * self->vec[x];
|
||||
test_v2 += tvec[x] * tvec[x];
|
||||
test_v1 += (double)(self->vec[x] * self->vec[x]);
|
||||
test_v2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
if (!test_v1 || !test_v2){
|
||||
/* avoid exception */
|
||||
@@ -608,7 +608,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
|
||||
|
||||
//dot product
|
||||
for(x = 0; x < self->size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
}
|
||||
dot /= (sqrt(test_v1) * sqrt(test_v2));
|
||||
|
||||
@@ -679,13 +679,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value)
|
||||
|
||||
//get dot products
|
||||
for(x = 0; x < size; x++) {
|
||||
dot += self->vec[x] * tvec[x];
|
||||
dot2 += tvec[x] * tvec[x];
|
||||
dot += (double)(self->vec[x] * tvec[x]);
|
||||
dot2 += (double)(tvec[x] * tvec[x]);
|
||||
}
|
||||
//projection
|
||||
dot /= dot2;
|
||||
for(x = 0; x < size; x++) {
|
||||
vec[x] = (float)(dot * tvec[x]);
|
||||
vec[x] = (float)dot * tvec[x];
|
||||
}
|
||||
return newVectorObject(vec, size, Py_NEW, Py_TYPE(self));
|
||||
}
|
||||
@@ -1034,7 +1034,7 @@ static int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject
|
||||
|
||||
for(x = 0; x < mat->col_size; x++) {
|
||||
for(y = 0; y < mat->row_size; y++) {
|
||||
dot += mat->matrix[y][x] * vec_cpy[y];
|
||||
dot += (double)(mat->matrix[y][x] * vec_cpy[y]);
|
||||
}
|
||||
rvec[z++] = (float)dot;
|
||||
dot = 0.0f;
|
||||
@@ -1079,7 +1079,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2)
|
||||
|
||||
/*dot product*/
|
||||
for(i = 0; i < vec1->size; i++) {
|
||||
dot += vec1->vec[i] * vec2->vec[i];
|
||||
dot += (double)(vec1->vec[i] * vec2->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(dot);
|
||||
}
|
||||
@@ -1257,7 +1257,7 @@ static double vec_magnitude_nosqrt(float *data, int size)
|
||||
int i;
|
||||
|
||||
for(i=0; i<size; i++){
|
||||
dot += data[i];
|
||||
dot += (double)data[i];
|
||||
}
|
||||
/*return (double)sqrt(dot);*/
|
||||
/* warning, line above removed because we are not using the length,
|
||||
@@ -1273,7 +1273,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa
|
||||
{
|
||||
VectorObject *vecA = NULL, *vecB = NULL;
|
||||
int result = 0;
|
||||
float epsilon = .000001f;
|
||||
double epsilon = .000001f;
|
||||
double lenA, lenB;
|
||||
|
||||
if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)){
|
||||
@@ -1499,7 +1499,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure))
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
dot += (self->vec[i] * self->vec[i]);
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
return PyFloat_FromDouble(sqrt(dot));
|
||||
}
|
||||
@@ -1517,17 +1517,17 @@ static int Vector_setLength(VectorObject *self, PyObject *value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (param < 0.0f) {
|
||||
if (param < 0.0) {
|
||||
PyErr_SetString(PyExc_TypeError, "cannot set a vectors length to a negative value");
|
||||
return -1;
|
||||
}
|
||||
if (param == 0.0f) {
|
||||
if (param == 0.0) {
|
||||
fill_vn(self->vec, self->size, 0.0f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(i = 0; i < self->size; i++){
|
||||
dot += (self->vec[i] * self->vec[i]);
|
||||
dot += (double)(self->vec[i] * self->vec[i]);
|
||||
}
|
||||
|
||||
if (!dot) /* cant sqrt zero */
|
||||
|
Reference in New Issue
Block a user