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
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-21 22:29:37 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-21 22:29:37 +0400
commitb8445173c4c8588a64870e93dd781d181d31c78b (patch)
treea94a5ab2198690f6ef16231627b77b0b8a337dec /source
parenta1407ff34215e5a72de2988e06c54379a1843c14 (diff)
2.5:
* Fix armature drawing crash with materials. * Mixed texture/material preview was doing wrong gamma correction. * Use *f math functions for AAO.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/preview/previewrender.c9
-rw-r--r--source/blender/gpu/intern/gpu_draw.c33
-rw-r--r--source/blender/render/intern/source/occlusion.c19
3 files changed, 40 insertions, 21 deletions
diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c
index 624952b48f5..b542b362ae0 100644
--- a/source/blender/editors/preview/previewrender.c
+++ b/source/blender/editors/preview/previewrender.c
@@ -472,9 +472,12 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, rcti *rect)
newrect.ymin= rect->ymin;
newrect.ymax= rect->ymin;
- ok= ed_preview_draw_rect(sa, sce, id, (parent != NULL), 1, rect, &newrect);
- if(parent)
- ok &= ed_preview_draw_rect(sa, sce, parent, 1, 0, rect, &newrect);
+ if(parent) {
+ ok = ed_preview_draw_rect(sa, sce, parent, 1, 1, rect, &newrect);
+ ok &= ed_preview_draw_rect(sa, sce, id, 1, 0, rect, &newrect);
+ }
+ else
+ ok = ed_preview_draw_rect(sa, sce, id, 0, 0, rect, &newrect);
if(ok)
*rect= newrect;
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 1031a240470..eb834abc670 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -800,7 +800,7 @@ static struct GPUMaterialState {
int lastmatnr, lastretval;
GPUBlendMode lastblendmode;
-} GMS;
+} GMS = {NULL};
Material *gpu_active_node_material(Material *ma)
{
@@ -930,10 +930,33 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
int GPU_enable_material(int nr, void *attribs)
{
+ extern Material defmaterial; /* from material.c */
GPUVertexAttribs *gattribs = attribs;
GPUMaterial *gpumat;
GPUBlendMode blendmode;
+ /* no GPU_begin_object_materials, use default material */
+ if(!GMS.matbuf) {
+ float diff[4], spec[4];
+
+ memset(&GMS, 0, sizeof(GMS));
+
+ diff[0]= (defmaterial.ref+defmaterial.emit)*defmaterial.r;
+ diff[1]= (defmaterial.ref+defmaterial.emit)*defmaterial.g;
+ diff[2]= (defmaterial.ref+defmaterial.emit)*defmaterial.b;
+ diff[3]= 1.0;
+
+ spec[0]= defmaterial.spec*defmaterial.specr;
+ spec[1]= defmaterial.spec*defmaterial.specg;
+ spec[2]= defmaterial.spec*defmaterial.specb;
+ spec[3]= 1.0;
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
+
+ return 0;
+ }
+
/* prevent index to use un-initialized array items */
if(nr>=GMS.totmat)
nr= 0;
@@ -1021,11 +1044,11 @@ void GPU_end_object_materials(void)
MEM_freeN(GMS.matbuf);
MEM_freeN(GMS.gmatbuf);
MEM_freeN(GMS.blendmode);
-
- GMS.matbuf= NULL;
- GMS.gmatbuf= NULL;
- GMS.blendmode= NULL;
}
+
+ GMS.matbuf= NULL;
+ GMS.gmatbuf= NULL;
+ GMS.blendmode= NULL;
}
/* Lights */
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index 1cbf2523156..feef3dd424a 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -754,9 +754,9 @@ static int occ_visible_quad(float *p, float *n, float *v0, float *v1, float *v2,
sd[1]= INPR(n, v1) - c;
sd[2]= INPR(n, v2) - c;
- if(fabs(sd[0]) < epsilon) sd[0] = 0.0f;
- if(fabs(sd[1]) < epsilon) sd[1] = 0.0f;
- if(fabs(sd[2]) < epsilon) sd[2] = 0.0f;
+ if(fabsf(sd[0]) < epsilon) sd[0] = 0.0f;
+ if(fabsf(sd[1]) < epsilon) sd[1] = 0.0f;
+ if(fabsf(sd[2]) < epsilon) sd[2] = 0.0f;
if(sd[0] > 0) {
if(sd[1] > 0) {
@@ -1086,13 +1086,6 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa
#endif
-static float saacosf(float fac)
-{
- if(fac<= -1.0f) return (float)M_PI;
- else if(fac>=1.0f) return 0.0f;
- else return acos(fac); /* acosf(fac) */
-}
-
static void normalizef(float *n)
{
float d;
@@ -1100,7 +1093,7 @@ static void normalizef(float *n)
d= INPR(n, n);
if(d > 1.0e-35F) {
- d= 1.0f/sqrt(d); /* sqrtf(d) */
+ d= 1.0f/sqrtf(d);
n[0] *= d;
n[1] *= d;
@@ -1222,7 +1215,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float
fac= 1.0f;
/* accumulate occlusion from spherical harmonics */
- invd2 = 1.0f/sqrt(d2);
+ invd2 = 1.0f/sqrtf(d2);
weight= occ_solid_angle(node, v, d2, invd2, n);
weight *= node->occlusion;
@@ -1258,7 +1251,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float
weight *= tree->occlusion[node->child[b].face];
if(bentn) {
- invd2= 1.0f/sqrt(d2);
+ invd2= 1.0f/sqrtf(d2);
bentn[0] -= weight*invd2*v[0];
bentn[1] -= weight*invd2*v[1];
bentn[2] -= weight*invd2*v[2];