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:
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c14
-rw-r--r--source/blender/editors/space_view3d/drawobject.c5
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c5
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c148
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c2
7 files changed, 105 insertions, 87 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index fb97a6ac9f4..fa9ba23e454 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -279,10 +279,10 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *
if (!ma && BKE_image_has_alpha(texface->tpage))
alphablend = GPU_BLEND_ALPHA;
}
- else if (texpaint && ma) {
+ else if (texpaint) {
if (gtexdraw.texpaint_material)
- ima = ma->texpaintslot ? ma->texpaintslot[ma->paint_active_slot].ima : NULL;
- else
+ ima = ma && ma->texpaintslot ? ma->texpaintslot[ma->paint_active_slot].ima : NULL;
+ else
ima = gtexdraw.canvas;
}
else
@@ -315,6 +315,14 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
+ glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);
+ glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_PREVIOUS);
+ glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
glActiveTexture(GL_TEXTURE0);
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index e7b6e50ef1c..d155918f7f9 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -302,7 +302,8 @@ bool draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt)
if (BKE_scene_use_new_shading_nodes(scene))
return false;
- return ((scene->gm.matmode == GAME_MAT_GLSL) || (v3d->drawtype == OB_MATERIAL)) && (dt > OB_SOLID);
+ return ((scene->gm.matmode == GAME_MAT_GLSL && v3d->drawtype == OB_TEXTURE) ||
+ (v3d->drawtype == OB_MATERIAL)) && (dt > OB_SOLID);
}
static bool check_alpha_pass(Base *base)
@@ -5181,7 +5182,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
/* restore & clean up */
if (1) { //ob_dt > OB_WIRE) {
if (part->draw_col == PART_DRAW_COL_MAT)
- glDisable(GL_COLOR_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_COLOR_MATERIAL);
}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 8b76ec3a56d..0e3621aa91f 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -698,10 +698,6 @@ static void view3d_main_area_free(ARegion *ar)
if (rv3d->localvd) MEM_freeN(rv3d->localvd);
if (rv3d->clipbb) MEM_freeN(rv3d->clipbb);
- if (rv3d->ri) {
- // XXX BIF_view3d_previewrender_free(rv3d);
- }
-
if (rv3d->render_engine)
RE_engine_free(rv3d->render_engine);
@@ -735,7 +731,6 @@ static void *view3d_main_area_duplicate(void *poin)
new->depths = NULL;
new->gpuoffscreen = NULL;
- new->ri = NULL;
new->render_engine = NULL;
new->sms = NULL;
new->smooth_timer = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 004b3e1b7d3..61bfb0176ef 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1091,6 +1091,9 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
/* passepartout, specified in camera edit buttons */
if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
+ const float winx = (ar->winx + 1);
+ const float winy = (ar->winy + 1);
+
if (ca->passepartalpha == 1.0f) {
glColor3f(0, 0, 0);
}
@@ -1100,11 +1103,11 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
glColor4f(0, 0, 0, ca->passepartalpha);
}
if (x1i > 0.0f)
- glRectf(0.0, (float)ar->winy, x1i, 0.0);
- if (x2i < (float)ar->winx)
- glRectf(x2i, (float)ar->winy, (float)ar->winx, 0.0);
- if (y2i < (float)ar->winy)
- glRectf(x1i, (float)ar->winy, x2i, y2i);
+ glRectf(0.0, winy, x1i, 0.0);
+ if (x2i < winx)
+ glRectf(x2i, winy, winx, 0.0);
+ if (y2i < winy)
+ glRectf(x1i, winy, x2i, y2i);
if (y2i > 0.0f)
glRectf(x1i, y1i, x2i, 0.0);
@@ -1585,6 +1588,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
int fg_flag = do_foreground ? V3D_BGPIC_FOREGROUND : 0;
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
+ bgpic->iuser.scene = scene; /* Needed for render results. */
if ((bgpic->flag & V3D_BGPIC_FOREGROUND) != fg_flag)
continue;
@@ -1598,9 +1602,10 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
float x1, y1, x2, y2;
ImBuf *ibuf = NULL, *freeibuf, *releaseibuf;
+ void *lock;
- Image *ima;
- MovieClip *clip;
+ Image *ima = NULL;
+ MovieClip *clip = NULL;
/* disable individual images */
if ((bgpic->flag & V3D_BGPIC_DISABLED))
@@ -1617,16 +1622,14 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
ibuf = NULL; /* frame is out of range, dont show */
}
else {
- ibuf = BKE_image_acquire_ibuf(ima, &bgpic->iuser, NULL);
+ ibuf = BKE_image_acquire_ibuf(ima, &bgpic->iuser, &lock);
releaseibuf = ibuf;
}
image_aspect[0] = ima->aspx;
- image_aspect[1] = ima->aspx;
+ image_aspect[1] = ima->aspy;
}
else if (bgpic->source == V3D_BGPIC_MOVIE) {
- clip = NULL;
-
/* TODO: skip drawing when out of frame range (as image sequences do above) */
if (bgpic->flag & V3D_BGPIC_CAMERACLIP) {
@@ -1664,7 +1667,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
if (freeibuf)
IMB_freeImBuf(freeibuf);
if (releaseibuf)
- BKE_image_release_ibuf(ima, releaseibuf, NULL);
+ BKE_image_release_ibuf(ima, releaseibuf, lock);
continue;
}
@@ -1763,7 +1766,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
if (freeibuf)
IMB_freeImBuf(freeibuf);
if (releaseibuf)
- BKE_image_release_ibuf(ima, releaseibuf, NULL);
+ BKE_image_release_ibuf(ima, releaseibuf, lock);
continue;
}
@@ -1830,7 +1833,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
if (freeibuf)
IMB_freeImBuf(freeibuf);
if (releaseibuf)
- BKE_image_release_ibuf(ima, releaseibuf, NULL);
+ BKE_image_release_ibuf(ima, releaseibuf, lock);
}
}
}
@@ -1981,8 +1984,10 @@ static void draw_dupli_objects_color(
GLuint displist = 0;
unsigned char color_rgb[3];
const short dflag_dupli = dflag | DRAW_CONSTCOLOR;
- short transflag, use_displist = -1; /* -1 is initialize */
+ short transflag;
+ bool use_displist = false; /* -1 is initialize */
char dt;
+ bool testbb = false;
short dtx;
DupliApplyData *apply_data;
@@ -2037,71 +2042,77 @@ static void draw_dupli_objects_color(
tbase.object->transflag |= OB_NEG_SCALE;
else
tbase.object->transflag &= ~OB_NEG_SCALE;
-
+
/* should move outside the loop but possible color is set in draw_object still */
if ((dflag & DRAW_CONSTCOLOR) == 0) {
glColor3ubv(color_rgb);
}
-
+
/* generate displist, test for new object */
if (dob_prev && dob_prev->ob != dob->ob) {
if (use_displist == true)
glDeleteLists(displist, 1);
-
- use_displist = -1;
+
+ use_displist = false;
+ }
+
+ if ((bb_tmp = BKE_object_boundbox_get(dob->ob))) {
+ bb = *bb_tmp; /* must make a copy */
+ testbb = true;
}
- /* generate displist */
- if (use_displist == -1) {
-
- /* note, since this was added, its checked (dob->type == OB_DUPLIGROUP)
- * however this is very slow, it was probably needed for the NLA
- * offset feature (used in group-duplicate.blend but no longer works in 2.5)
- * so for now it should be ok to - campbell */
-
- if ( /* if this is the last no need to make a displist */
- (dob_next == NULL || dob_next->ob != dob->ob) ||
- /* lamp drawing messes with matrices, could be handled smarter... but this works */
- (dob->ob->type == OB_LAMP) ||
- (dob->type == OB_DUPLIGROUP && dob->animated) ||
- !(bb_tmp = BKE_object_boundbox_get(dob->ob)) ||
- draw_glsl_material(scene, dob->ob, v3d, dt) ||
- check_object_draw_texture(scene, v3d, dt) ||
- (base->object == OBACT && v3d->flag2 & V3D_SOLID_MATCAP))
- {
- // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name + 2);
- use_displist = false;
- }
- else {
- // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2);
- bb = *bb_tmp; /* must make a copy */
-
- /* disable boundbox check for list creation */
- BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1);
- /* need this for next part of code */
- unit_m4(dob->ob->obmat); /* obmat gets restored */
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE);
- draw_object(scene, ar, v3d, &tbase, dflag_dupli);
- glEndList();
-
- use_displist = true;
- BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0);
+ if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) {
+ /* generate displist */
+ if (use_displist == false) {
+
+ /* note, since this was added, its checked (dob->type == OB_DUPLIGROUP)
+ * however this is very slow, it was probably needed for the NLA
+ * offset feature (used in group-duplicate.blend but no longer works in 2.5)
+ * so for now it should be ok to - campbell */
+
+ if ( /* if this is the last no need to make a displist */
+ (dob_next == NULL || dob_next->ob != dob->ob) ||
+ /* lamp drawing messes with matrices, could be handled smarter... but this works */
+ (dob->ob->type == OB_LAMP) ||
+ (dob->type == OB_DUPLIGROUP && dob->animated) ||
+ !bb_tmp ||
+ draw_glsl_material(scene, dob->ob, v3d, dt) ||
+ check_object_draw_texture(scene, v3d, dt) ||
+ (v3d->flag2 & V3D_SOLID_MATCAP) != 0)
+ {
+ // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name + 2);
+ use_displist = false;
+ }
+ else {
+ // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2);
+
+ /* disable boundbox check for list creation */
+ BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1);
+ /* need this for next part of code */
+ unit_m4(dob->ob->obmat); /* obmat gets restored */
+
+ displist = glGenLists(1);
+ glNewList(displist, GL_COMPILE);
+ draw_object(scene, ar, v3d, &tbase, dflag_dupli);
+ glEndList();
+
+ use_displist = true;
+ BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0);
+ }
}
- }
- if (use_displist) {
- if (ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) {
+
+ if (use_displist) {
+ glPushMatrix();
glMultMatrixf(dob->mat);
glCallList(displist);
- glLoadMatrixf(rv3d->viewmat);
+ glPopMatrix();
+ }
+ else {
+ copy_m4_m4(dob->ob->obmat, dob->mat);
+ draw_object(scene, ar, v3d, &tbase, dflag_dupli);
}
}
- else {
- copy_m4_m4(dob->ob->obmat, dob->mat);
- draw_object(scene, ar, v3d, &tbase, dflag_dupli);
- }
-
+
tbase.object->dt = dt;
tbase.object->dtx = dtx;
tbase.object->transflag = transflag;
@@ -2473,7 +2484,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
v3d->drawtype = OB_SOLID;
v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp);
- v3d->flag2 &= ~V3D_SOLID_TEX | V3D_SHOW_SOLID_MATCAP;
+ v3d->flag2 &= ~(V3D_SOLID_TEX | V3D_SHOW_SOLID_MATCAP);
v3d->flag2 |= V3D_RENDER_OVERRIDE | V3D_RENDER_SHADOW;
GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat);
@@ -2515,8 +2526,11 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d)
mask |= CD_MASK_ORCO;
}
else {
- if (scene->gm.matmode == GAME_MAT_GLSL || v3d->drawtype == OB_MATERIAL)
+ if ((scene->gm.matmode == GAME_MAT_GLSL && v3d->drawtype == OB_TEXTURE) ||
+ (v3d->drawtype == OB_MATERIAL))
+ {
mask |= CD_MASK_ORCO;
+ }
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index db675b09896..f54e7ae06f6 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1037,8 +1037,8 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
* - dragged. */
phi = si * (float)(M_PI / 2.0);
- q1[0] = cos(phi);
- mul_v3_fl(q1 + 1, sin(phi));
+ q1[0] = cosf(phi);
+ mul_v3_fl(q1 + 1, sinf(phi));
mul_qt_qtqt(vod->viewquat, q1, vod->oldquat);
viewrotate_apply_dyn_ofs(vod, vod->viewquat);
@@ -1448,7 +1448,7 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, ScrArea *sa,
/* Perform the up/down rotation */
angle = ndof->dt * rot[0];
quat[0] = cosf(angle);
- mul_v3_v3fl(quat + 1, xvec, sin(angle));
+ mul_v3_v3fl(quat + 1, xvec, sinf(angle));
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, quat);
/* Perform the orbital rotation */
@@ -3423,7 +3423,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* find the closest Z pixel */
depth_close = view3d_depth_near(&depth_temp);
- MEM_freeN(depth_temp.depths);
+ MEM_SAFE_FREE(depth_temp.depths);
}
cent[0] = (((double)rect.xmin) + ((double)rect.xmax)) / 2;
@@ -4640,7 +4640,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
view3d_update_depths_rect(ar, &depth_temp, &rect);
depth_close = view3d_depth_near(&depth_temp);
- if (depth_temp.depths) MEM_freeN(depth_temp.depths);
+ MEM_SAFE_FREE(depth_temp.depths);
return depth_close;
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 46ea52054c5..ae429289ffd 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1181,14 +1181,14 @@ static short selectbuffer_ret_hits_15(unsigned int *UNUSED(buffer), const short
static short selectbuffer_ret_hits_9(unsigned int *buffer, const short hits15, const short hits9)
{
const int offs = 4 * hits15;
- memcpy(buffer, buffer + offs, 4 * offs);
+ memcpy(buffer, buffer + offs, 4 * hits9);
return hits9;
}
static short selectbuffer_ret_hits_5(unsigned int *buffer, const short hits15, const short hits9, const short hits5)
{
const int offs = 4 * hits15 + 4 * hits9;
- memcpy(buffer, buffer + offs, 4 * offs);
+ memcpy(buffer, buffer + offs, 4 * hits5);
return hits5;
}
@@ -1522,7 +1522,7 @@ static bool mouse_select(bContext *C, const int mval[2],
}
}
}
- else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend, deselect, toggle) ) {
+ else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend, deselect, toggle, do_nearest)) {
/* then bone is found */
/* we make the armature selected:
@@ -1972,7 +1972,7 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool
ED_armature_sync_selection(arm->edbo);
- return OPERATOR_CANCELLED;
+ return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, bool select, bool extend)
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 7bdf39d6768..c54948b23c6 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -961,7 +961,7 @@ static int walkApply(bContext *C, WalkInfo *walk)
/* clamp the angle limits */
/* it ranges from 90.0f to -90.0f */
- angle = -asin(rv3d->viewmat[2][2]);
+ angle = -asinf(rv3d->viewmat[2][2]);
if (angle > WALK_TOP_LIMIT && y > 0.0f)
y = 0.0f;