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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-04 10:20:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-04 10:20:10 +0400
commitd0cdefd9fa37bf6788dad27b87d8d569c58ad94a (patch)
tree8807f7717662ad96cf6ad1d8df0a5caa12162361 /source/blender
parent8d8403c15ec8694d7d71d8a9f4a9e3a1fade666e (diff)
parent434c1e6df82a082fe03034a3ad3825f7b50ea533 (diff)
svn merge ^/trunk/blender -r43092:43092
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenfont/intern/blf.c31
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c10
-rw-r--r--source/blender/blenkernel/intern/object.c49
-rw-r--r--source/blender/gpu/intern/gpu_material.c6
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h31
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c38
-rw-r--r--source/blender/modifiers/intern/MOD_util.c41
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c62
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c91
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c18
-rw-r--r--source/blender/render/intern/source/render_texture.c5
11 files changed, 111 insertions, 271 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 9b26e7a54be..f8018e05431 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -479,7 +479,7 @@ void BLF_rotation_default(float angle)
}
}
-static void blf_draw__start(FontBLF *font)
+static void blf_draw__start(FontBLF *font, GLint *mode)
{
/*
* The pixmap alignment hack is handle
@@ -490,6 +490,14 @@ static void blf_draw__start(FontBLF *font)
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ /* Save the current matrix mode. */
+ glGetIntegerv(GL_MATRIX_MODE, mode);
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (font->flags & BLF_MATRIX)
@@ -508,12 +516,19 @@ static void blf_draw__start(FontBLF *font)
/* always bind the texture for the first glyph */
font->tex_bind_state= -1;
-
}
-static void blf_draw__end(void)
+static void blf_draw__end(GLint mode)
{
+ glMatrixMode(GL_TEXTURE);
glPopMatrix();
+
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
+ if (mode != GL_MODELVIEW)
+ glMatrixMode(mode);
+
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}
@@ -521,22 +536,24 @@ static void blf_draw__end(void)
void BLF_draw(int fontid, const char *str, size_t len)
{
FontBLF *font= BLF_get(fontid);
+ GLint mode;
if (font && font->glyph_cache) {
- blf_draw__start(font);
+ blf_draw__start(font, &mode);
blf_font_draw(font, str, len);
- blf_draw__end();
+ blf_draw__end(mode);
}
}
void BLF_draw_ascii(int fontid, const char *str, size_t len)
{
FontBLF *font= BLF_get(fontid);
+ GLint mode;
if (font && font->glyph_cache) {
- blf_draw__start(font);
+ blf_draw__start(font, &mode);
blf_font_draw_ascii(font, str, len);
- blf_draw__end();
+ blf_draw__end(mode);
}
}
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index f0cfcdc97b9..f8c589a7051 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -368,6 +368,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
float dx, dx1;
float y1, y2;
float xo, yo;
+ GLint param;
if ((!g->width) || (!g->height))
return 1;
@@ -449,6 +450,11 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state= g->tex));
}
+ /* Save the current parameter to restore it later. */
+ glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &param);
+ if (param != GL_MODULATE)
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
if (font->flags & BLF_SHADOW) {
switch(font->shadow) {
@@ -487,5 +493,9 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
break;
}
+ /* and restore the original value. */
+ if (param != GL_MODULATE)
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
+
return 1;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index e95be394076..8424824903e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -431,7 +431,8 @@ void unlink_object(Object *ob)
if(pchan->custom==ob)
pchan->custom= NULL;
}
- } else if(ELEM(OB_MBALL, ob->type, obt->type)) {
+ }
+ else if(ELEM(OB_MBALL, ob->type, obt->type)) {
if(is_mball_basis_for(obt, ob))
obt->recalc|= OB_RECALC_DATA;
}
@@ -609,21 +610,6 @@ void unlink_object(Object *ob)
sce= sce->id.next;
}
-#if 0 // XXX old animation system
- /* ipos */
- ipo= bmain->ipo.first;
- while(ipo) {
- if(ipo->id.lib==NULL) {
- IpoCurve *icu;
- for(icu= ipo->curve.first; icu; icu= icu->next) {
- if(icu->driver && icu->driver->ob==ob)
- icu->driver->ob= NULL;
- }
- }
- ipo= ipo->id.next;
- }
-#endif // XXX old animation system
-
/* screens */
sc= bmain->screen.first;
while(sc) {
@@ -991,7 +977,7 @@ void copy_object_particlesystems(Object *obn, Object *ob)
}
else if (md->type==eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData*) md;
-
+
if(smd->type==MOD_SMOKE_TYPE_FLOW) {
if (smd->flow) {
if (smd->flow->psys == psys)
@@ -1027,22 +1013,6 @@ static void copy_object_pose(Object *obn, Object *ob)
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-#if 0 // XXX old animation system
- /* note that we can't change lib linked ipo blocks. for making
- * proxies this still works correct however because the object
- * is changed to object->proxy_from when evaluating the driver. */
- if(con->ipo && !con->ipo->id.lib) {
- IpoCurve *icu;
-
- con->ipo= copy_ipo(con->ipo);
-
- for(icu= con->ipo->curve.first; icu; icu= icu->next) {
- if(icu->driver && icu->driver->ob==ob)
- icu->driver->ob= obn;
- }
- }
-#endif // XXX old animation system
-
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
@@ -1072,8 +1042,7 @@ static int object_pose_context(Object *ob)
}
}
-//Object *object_pose_armature_get(Object *ob)
-Object *object_pose_armature_get(struct Object *ob)
+Object *object_pose_armature_get(Object *ob)
{
if(ob==NULL)
return NULL;
@@ -1179,13 +1148,8 @@ Object *copy_object(Object *ob)
static void extern_local_object(Object *ob)
{
- //bActionStrip *strip;
ParticleSystem *psys;
-#if 0 // XXX old animation system
- id_lib_extern((ID *)ob->action);
- id_lib_extern((ID *)ob->ipo);
-#endif // XXX old animation system
id_lib_extern((ID *)ob->data);
id_lib_extern((ID *)ob->dup_group);
id_lib_extern((ID *)ob->poselib);
@@ -1193,11 +1157,6 @@ static void extern_local_object(Object *ob)
extern_local_matarar(ob->mat, ob->totcol);
-#if 0 // XXX old animation system
- for (strip=ob->nlastrips.first; strip; strip=strip->next) {
- id_lib_extern((ID *)strip->act);
- }
-#endif // XXX old animation system
for(psys=ob->particlesystem.first; psys; psys=psys->next)
id_lib_extern((ID *)psys->part);
}
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index fb1d10b5491..93ea067cfb7 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -1120,7 +1120,11 @@ static void do_material_tex(GPUShadeInput *shi)
// to inverting the bump map. Should this ever change
// this negate must be removed.
norfac = -hScale * mtex->norfac;
- if(found_deriv_map) norfac /= sqrtf(ima_x*ima_y);
+ if(found_deriv_map)
+ {
+ float fVirtDim = sqrtf(fabsf(ima_x*mtex->size[0]*ima_y*mtex->size[1]));
+ norfac /= MAX2(fVirtDim, FLT_EPSILON);
+ }
tnorfac = GPU_uniform(&norfac);
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index dd68694404d..2d6143a1bc2 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -316,13 +316,13 @@ typedef struct DisplaceModifierData {
char uvlayer_name[32];
int uvlayer_tmp;
int texmapping;
- int pad10;
/* end MappingInfoModifierData */
float strength;
int direction;
char defgrp_name[32];
float midlevel;
+ int pad;
} DisplaceModifierData;
/* DisplaceModifierData->direction */
@@ -339,7 +339,7 @@ enum {
MOD_DISP_MAP_LOCAL,
MOD_DISP_MAP_GLOBAL,
MOD_DISP_MAP_OBJECT,
- MOD_DISP_MAP_UV,
+ MOD_DISP_MAP_UV
};
typedef struct UVProjectModifierData {
@@ -404,13 +404,6 @@ typedef struct CastModifierData {
short flag, type;
} CastModifierData;
-enum {
- MOD_WAV_MAP_LOCAL,
- MOD_WAV_MAP_GLOBAL,
- MOD_WAV_MAP_OBJECT,
- MOD_WAV_MAP_UV,
-};
-
/* WaveModifierData.flag */
#define MOD_WAVE_X (1<<1)
#define MOD_WAVE_Y (1<<2)
@@ -423,20 +416,22 @@ enum {
typedef struct WaveModifierData {
ModifierData modifier;
- struct Object *objectcenter;
- char defgrp_name[32];
+ /* keep in sync with MappingInfoModifierData */
struct Tex *texture;
struct Object *map_object;
+ char uvlayer_name[32];
+ int uvlayer_tmp;
+ int texmapping;
+ /* end MappingInfoModifierData */
+
+ struct Object *objectcenter;
+ char defgrp_name[32];
short flag, pad;
float startx, starty, height, width;
float narrow, speed, damp, falloff;
- int texmapping, uvlayer_tmp;
-
- char uvlayer_name[32];
-
float timeoffs, lifetime;
float pad1;
} WaveModifierData;
@@ -831,19 +826,17 @@ typedef struct WarpModifierData {
char uvlayer_name[32];
int uvlayer_tmp;
int texmapping;
- int pad10;
/* end MappingInfoModifierData */
- float strength;
-
struct Object *object_from;
struct Object *object_to;
struct CurveMapping *curfalloff;
char defgrp_name[32]; /* optional vertexgroup name */
+ float strength;
float falloff_radius;
char flag; /* not used yet */
char falloff_type;
- char pad[2];
+ char pad[6];
} WarpModifierData;
#define MOD_WARP_VOLUME_PRESERVE 1
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 98db305e750..cc046a75a8f 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -455,12 +455,6 @@ static void RNA_WarpModifier_vgroup_set(PointerRNA *ptr, const char *value)
rna_object_vgroup_name_set(ptr, value, tmd->defgrp_name, sizeof(tmd->defgrp_name));
}
-static void rna_WaveModifier_uvlayer_set(PointerRNA *ptr, const char *value)
-{
- WaveModifierData *wmd= (WaveModifierData*)ptr->data;
- rna_object_uvlayer_name_set(ptr, value, wmd->uvlayer_name, sizeof(wmd->uvlayer_name));
-}
-
static void rna_WeightVGModifier_mask_uvlayer_set(PointerRNA *ptr, const char *value)
{
ModifierData *md = (ModifierData*)ptr->data;
@@ -1128,13 +1122,6 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem prop_texture_coordinates_items[] = {
- {MOD_WAV_MAP_LOCAL, "LOCAL", 0, "Local", ""},
- {MOD_WAV_MAP_GLOBAL, "GLOBAL", 0, "Global", ""},
- {MOD_WAV_MAP_OBJECT, "OBJECT", 0, "Object", ""},
- {MOD_WAV_MAP_UV, "MAP_UV", 0, "UV", ""},
- {0, NULL, 0, NULL, NULL}};
-
srna= RNA_def_struct(brna, "WaveModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Wave Modifier", "Wave effect modifier");
RNA_def_struct_sdna(srna, "WaveModifierData");
@@ -1226,29 +1213,6 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WaveModifier_vgroup_set");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
- prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
- RNA_def_property_ui_text(prop, "Texture", "Texture for modulating the wave");
- RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "texmapping");
- RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
- RNA_def_property_ui_text(prop, "Texture Coordinates", "Texture coordinates used for modulating input");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
- RNA_def_property_ui_text(prop, "UV Map", "UV map name");
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WaveModifier_uvlayer_set");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "texture_coords_object", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "map_object");
- RNA_def_property_ui_text(prop, "Texture Coordinates Object", "");
- RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
- RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
-
prop= RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -1, 1, 10, 2);
@@ -1273,6 +1237,8 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0, 10, 10, 2);
RNA_def_property_ui_text(prop, "Narrowness", "Distance between the top and the base of a wave, the higher the value, the more narrow the wave");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ rna_def_modifier_generic_map_info(srna);
}
static void rna_def_modifier_armature(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 8c2b86094f1..6d2e2b42405 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -107,36 +107,19 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
/* verts are given the UV from the first face that uses them */
for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tf) {
- if(!done[mf->v1]) {
- texco[mf->v1][0] = tf->uv[0][0];
- texco[mf->v1][1] = tf->uv[0][1];
- texco[mf->v1][2] = 0;
- done[mf->v1] = 1;
- }
- if(!done[mf->v2]) {
- texco[mf->v2][0] = tf->uv[1][0];
- texco[mf->v2][1] = tf->uv[1][1];
- texco[mf->v2][2] = 0;
- done[mf->v2] = 1;
- }
- if(!done[mf->v3]) {
- texco[mf->v3][0] = tf->uv[2][0];
- texco[mf->v3][1] = tf->uv[2][1];
- texco[mf->v3][2] = 0;
- done[mf->v3] = 1;
- }
- if(!done[mf->v4]) {
- texco[mf->v4][0] = tf->uv[3][0];
- texco[mf->v4][1] = tf->uv[3][1];
- texco[mf->v4][2] = 0;
- done[mf->v4] = 1;
- }
- }
+ unsigned int fidx= mf->v4 ? 3:2;
+
+ do {
+ unsigned int vidx = *(&mf->v1 + fidx);
+
+ if (done[vidx] == 0) {
+ /* remap UVs from [0, 1] to [-1, 1] */
+ texco[vidx][0] = (tf->uv[fidx][0] * 2.0f) - 1.0f;
+ texco[vidx][1] = (tf->uv[fidx][1] * 2.0f) - 1.0f;
+ done[vidx] = 1;
+ }
- /* remap UVs from [0, 1] to [-1, 1] */
- for(i = 0; i < numVerts; ++i) {
- texco[i][0] = texco[i][0] * 2 - 1;
- texco[i][1] = texco[i][1] * 2 - 1;
+ } while (fidx--);
}
MEM_freeN(done);
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index d7c78492f92..2aed6f05277 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -288,41 +288,34 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
if(override_image || !image || tface->tpage == image) {
if(num_projectors == 1) {
if(projectors[0].uci) {
- project_from_camera(tface->uv[0], coords[mf->v1], projectors[0].uci);
- project_from_camera(tface->uv[1], coords[mf->v2], projectors[0].uci);
- project_from_camera(tface->uv[2], coords[mf->v3], projectors[0].uci);
- if(mf->v4)
- project_from_camera(tface->uv[3], coords[mf->v4], projectors[0].uci);
+ unsigned int fidx= mf->v4 ? 3:2;
+ do {
+ unsigned int vidx= *(&mf->v1 + fidx);
+ project_from_camera(tface->uv[fidx], coords[vidx], projectors[0].uci);
+ } while (fidx--);
}
else {
/* apply transformed coords as UVs */
- copy_v2_v2(tface->uv[0], coords[mf->v1]);
- copy_v2_v2(tface->uv[1], coords[mf->v2]);
- copy_v2_v2(tface->uv[2], coords[mf->v3]);
- if (mf->v4) {
- copy_v2_v2(tface->uv[3], coords[mf->v4]);
- }
+ unsigned int fidx= mf->v4 ? 3:2;
+ do {
+ unsigned int vidx= *(&mf->v1 + fidx);
+ copy_v2_v2(tface->uv[fidx], coords[vidx]);
+ } while (fidx--);
}
} else {
/* multiple projectors, select the closest to face normal
* direction
*/
- float co1[3], co2[3], co3[3], co4[3];
float face_no[3];
int j;
Projector *best_projector;
float best_dot;
- copy_v3_v3(co1, coords[mf->v1]);
- copy_v3_v3(co2, coords[mf->v2]);
- copy_v3_v3(co3, coords[mf->v3]);
-
/* get the untransformed face normal */
if(mf->v4) {
- copy_v3_v3(co4, coords[mf->v4]);
- normal_quad_v3(face_no, co1, co2, co3, co4);
+ normal_quad_v3(face_no, coords[mf->v1], coords[mf->v2], coords[mf->v3], coords[mf->v4]);
} else {
- normal_tri_v3(face_no, co1, co2, co3);
+ normal_tri_v3(face_no, coords[mf->v1], coords[mf->v2], coords[mf->v3]);
}
/* find the projector which the face points at most directly
@@ -341,26 +334,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
}
if(best_projector->uci) {
- project_from_camera(tface->uv[0], coords[mf->v1], best_projector->uci);
- project_from_camera(tface->uv[1], coords[mf->v2], best_projector->uci);
- project_from_camera(tface->uv[2], coords[mf->v3], best_projector->uci);
- if(mf->v4)
- project_from_camera(tface->uv[3], coords[mf->v4], best_projector->uci);
+ unsigned int fidx= mf->v4 ? 3:2;
+ do {
+ unsigned int vidx= *(&mf->v1 + fidx);
+ project_from_camera(tface->uv[fidx], coords[vidx], best_projector->uci);
+ } while (fidx--);
}
else {
- mul_project_m4_v3(best_projector->projmat, co1);
- mul_project_m4_v3(best_projector->projmat, co2);
- mul_project_m4_v3(best_projector->projmat, co3);
- if(mf->v4)
- mul_project_m4_v3(best_projector->projmat, co4);
+ unsigned int fidx= mf->v4 ? 3:2;
+ do {
+ unsigned int vidx= *(&mf->v1 + fidx);
+ float tco[3];
- /* apply transformed coords as UVs */
- copy_v2_v2(tface->uv[0], co1);
- copy_v2_v2(tface->uv[1], co2);
- copy_v2_v2(tface->uv[2], co3);
- if (mf->v4) {
- copy_v2_v2(tface->uv[3], co4);
- }
+ copy_v3_v3(tco, coords[vidx]);
+ mul_project_m4_v3(best_projector->projmat, tco);
+ copy_v2_v2(tface->uv[fidx], tco);
+
+ } while (fidx--);
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 6e3673f0549..cb2f6f4d6bc 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -73,7 +73,7 @@ static void initData(ModifierData *md)
wmd->lifetime= 0.0f;
wmd->damp= 10.0f;
wmd->falloff= 0.0f;
- wmd->texmapping = MOD_WAV_MAP_LOCAL;
+ wmd->texmapping = MOD_DISP_MAP_LOCAL;
wmd->defgrp_name[0] = 0;
}
@@ -160,7 +160,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
/* ask for UV coordinates if we need them */
- if(wmd->texture && wmd->texmapping == MOD_WAV_MAP_UV)
+ if(wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV)
dataMask |= CD_MASK_MTFACE;
/* ask for vertexgroups if we need them */
@@ -170,91 +170,6 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob,
- DerivedMesh *dm,
- float (*co)[3], float (*texco)[3],
- int numVerts)
-{
- int i;
- int texmapping = wmd->texmapping;
-
- if(texmapping == MOD_WAV_MAP_OBJECT) {
- if(wmd->map_object)
- invert_m4_m4(wmd->map_object->imat, wmd->map_object->obmat);
- else /* if there is no map object, default to local */
- texmapping = MOD_WAV_MAP_LOCAL;
- }
-
- /* UVs need special handling, since they come from faces */
- if(texmapping == MOD_WAV_MAP_UV) {
- if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) {
- MFace *mface = dm->getTessFaceArray(dm);
- MFace *mf;
- char *done = MEM_callocN(sizeof(*done) * numVerts,
- "get_texture_coords done");
- int numFaces = dm->getNumTessFaces(dm);
- char uvname[32];
- MTFace *tf;
-
- CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, wmd->uvlayer_name, uvname);
- tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
-
- /* verts are given the UV from the first face that uses them */
- for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tf) {
- if(!done[mf->v1]) {
- texco[mf->v1][0] = tf->uv[0][0];
- texco[mf->v1][1] = tf->uv[0][1];
- texco[mf->v1][2] = 0;
- done[mf->v1] = 1;
- }
- if(!done[mf->v2]) {
- texco[mf->v2][0] = tf->uv[1][0];
- texco[mf->v2][1] = tf->uv[1][1];
- texco[mf->v2][2] = 0;
- done[mf->v2] = 1;
- }
- if(!done[mf->v3]) {
- texco[mf->v3][0] = tf->uv[2][0];
- texco[mf->v3][1] = tf->uv[2][1];
- texco[mf->v3][2] = 0;
- done[mf->v3] = 1;
- }
- if(!done[mf->v4]) {
- texco[mf->v4][0] = tf->uv[3][0];
- texco[mf->v4][1] = tf->uv[3][1];
- texco[mf->v4][2] = 0;
- done[mf->v4] = 1;
- }
- }
-
- /* remap UVs from [0, 1] to [-1, 1] */
- for(i = 0; i < numVerts; ++i) {
- texco[i][0] = texco[i][0] * 2 - 1;
- texco[i][1] = texco[i][1] * 2 - 1;
- }
-
- MEM_freeN(done);
- return;
- } else /* if there are no UVs, default to local */
- texmapping = MOD_WAV_MAP_LOCAL;
- }
-
- for(i = 0; i < numVerts; ++i, ++co, ++texco) {
- switch(texmapping) {
- case MOD_WAV_MAP_LOCAL:
- copy_v3_v3(*texco, *co);
- break;
- case MOD_WAV_MAP_GLOBAL:
- mul_v3_m4v3(*texco, ob->obmat, *co);
- break;
- case MOD_WAV_MAP_OBJECT:
- mul_v3_m4v3(*texco, ob->obmat, *co);
- mul_m4_v3(wmd->map_object->imat, *texco);
- break;
- }
- }
-}
-
static void waveModifier_do(WaveModifierData *md,
Scene *scene, Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
@@ -305,7 +220,7 @@ static void waveModifier_do(WaveModifierData *md,
if(wmd->texture) {
tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts,
"waveModifier_do tex_co");
- wavemod_get_texture_coords(wmd, ob, dm, vertexCos, tex_co, numVerts);
+ get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts);
}
if(lifefac != 0.0f) {
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index e137c7846bb..5848e6e8c75 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -334,18 +334,18 @@ PyDoc_STRVAR(Vector_normalize_doc,
"\n"
" Normalize the vector, making the length of the vector always 1.0.\n"
"\n"
-" .. warning:: Normalizing a vector where all values are zero results\n"
-" in all axis having a nan value (not a number).\n"
+" .. warning:: Normalizing a vector where all values are zero has no effect.\n"
"\n"
" .. note:: Normalize works for vectors of all sizes,\n"
" however 4D Vectors w axis is left untouched.\n"
);
static PyObject *Vector_normalize(VectorObject *self)
{
+ int size = (self->size == 4 ? 3 : self->size);
if (BaseMath_ReadCallback(self) == -1)
return NULL;
- normalize_vn(self->vec, self->size);
+ normalize_vn(self->vec, size);
(void)BaseMath_WriteCallback(self);
Py_RETURN_NONE;
@@ -1480,10 +1480,10 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2)
mulplication*/
-/* COLUMN VECTOR Multiplication (Vector X Matrix)
- * [a] * [1][4][7]
- * [b] * [2][5][8]
- * [c] * [3][6][9]
+/* COLUMN VECTOR Multiplication (Matrix X Vector)
+ * [1][4][7] [a]
+ * [2][5][8] * [b]
+ * [3][6][9] [c]
*
* note: vector/matrix multiplication IS NOT COMMUTATIVE!!!!
* note: assume read callbacks have been done first.
@@ -1500,8 +1500,8 @@ int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec,
else {
PyErr_SetString(PyExc_TypeError,
"matrix * vector: "
- "matrix.row_size and len(vector) must be the same, "
- "except for 3D vector * 4x4 matrix.");
+ "len(matrix.col) and len(vector) must be the same, "
+ "except for 4x4 matrix * 3D vector.");
return -1;
}
}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 849e0ef428a..e19b4a1e669 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -1969,7 +1969,10 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
{
auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale;
}
- auto_bump /= sqrtf((float) (dimx*dimy));
+ {
+ float fVirtDim = sqrtf(fabsf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1]));
+ auto_bump /= MAX2(fVirtDim, FLT_EPSILON);
+ }
// this variant using a derivative map is described here
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html