2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-19 12:14:58 +00:00
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-19 12:14:58 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation, full update, glsl support
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_view3d/drawmesh.c
|
|
|
|
|
* \ingroup spview3d
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BLI_edgehash.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_property_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_material.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_property.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
2010-07-14 10:46:12 +00:00
|
|
|
#include "GPU_buffers.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
#include "GPU_draw.h"
|
|
|
|
|
|
2008-12-30 13:16:14 +00:00
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "view3d_intern.h" // own include
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/**************************** Face Select Mode *******************************/
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/* Flags for marked edges */
|
2008-12-19 12:14:58 +00:00
|
|
|
enum {
|
|
|
|
|
eEdge_Visible = (1<<0),
|
|
|
|
|
eEdge_Select = (1<<1),
|
|
|
|
|
};
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/* Creates a hash of edges to flags indicating selected/visible */
|
2008-12-19 12:14:58 +00:00
|
|
|
static void get_marked_edge_info__orFlags(EdgeHash *eh, int v0, int v1, int flags)
|
|
|
|
|
{
|
|
|
|
|
int *flags_p;
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
if(!BLI_edgehash_haskey(eh, v0, v1))
|
2011-03-03 17:59:04 +00:00
|
|
|
BLI_edgehash_insert(eh, v0, v1, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
flags_p = (int*) BLI_edgehash_lookup_p(eh, v0, v1);
|
|
|
|
|
*flags_p |= flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
|
|
|
|
|
{
|
|
|
|
|
EdgeHash *eh = BLI_edgehash_new();
|
|
|
|
|
MFace *mf;
|
2011-08-12 18:13:55 +00:00
|
|
|
int i;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
for(i=0; i<me->totface; i++) {
|
2008-12-19 12:14:58 +00:00
|
|
|
mf = &me->mface[i];
|
2011-01-12 03:41:12 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
if(!(mf->flag & ME_HIDE)) {
|
|
|
|
|
unsigned int flags = eEdge_Visible;
|
|
|
|
|
if(mf->flag & ME_FACE_SEL) flags |= eEdge_Select;
|
|
|
|
|
|
|
|
|
|
get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, flags);
|
|
|
|
|
get_marked_edge_info__orFlags(eh, mf->v2, mf->v3, flags);
|
|
|
|
|
|
|
|
|
|
if(mf->v4) {
|
|
|
|
|
get_marked_edge_info__orFlags(eh, mf->v3, mf->v4, flags);
|
|
|
|
|
get_marked_edge_info__orFlags(eh, mf->v4, mf->v1, flags);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
|
|
|
|
get_marked_edge_info__orFlags(eh, mf->v3, mf->v1, flags);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return eh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
static int draw_mesh_face_select__setHiddenOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
struct { Mesh *me; EdgeHash *eh; } *data = userData;
|
2009-01-31 13:30:56 +00:00
|
|
|
Mesh *me= data->me;
|
|
|
|
|
MEdge *med = &me->medge[index];
|
2008-12-19 12:14:58 +00:00
|
|
|
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
if(me->drawflag & ME_DRAWEDGES) {
|
|
|
|
|
if(me->drawflag & ME_HIDDENEDGES)
|
2008-12-19 12:14:58 +00:00
|
|
|
return 1;
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
2008-12-19 12:14:58 +00:00
|
|
|
return (flags & eEdge_Visible);
|
|
|
|
|
}
|
2011-08-12 18:13:55 +00:00
|
|
|
else
|
|
|
|
|
return (flags & eEdge_Select);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
static int draw_mesh_face_select__setSelectOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
struct { Mesh *me; EdgeHash *eh; } *data = userData;
|
|
|
|
|
MEdge *med = &data->me->medge[index];
|
|
|
|
|
uintptr_t flags = (intptr_t) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
|
|
|
|
|
|
|
|
|
|
return flags & eEdge_Select;
|
|
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
|
2010-10-19 15:35:46 +00:00
|
|
|
/* draws unselected */
|
2011-08-12 18:13:55 +00:00
|
|
|
static int draw_mesh_face_select__drawFaceOptsInv(void *userData, int index)
|
2010-10-19 15:35:46 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = (Mesh*)userData;
|
|
|
|
|
|
|
|
|
|
MFace *mface = &me->mface[index];
|
2011-08-12 18:13:55 +00:00
|
|
|
if(!(mface->flag&ME_HIDE) && !(mface->flag&ME_FACE_SEL))
|
2010-10-19 15:35:46 +00:00
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
static void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
struct { Mesh *me; EdgeHash *eh; } data;
|
|
|
|
|
|
|
|
|
|
data.me = me;
|
|
|
|
|
data.eh = get_tface_mesh_marked_edge_info(me);
|
|
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-10-19 15:35:46 +00:00
|
|
|
/* Draw (Hidden) Edges */
|
|
|
|
|
setlinestyle(1);
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColor(TH_EDGE_FACESEL);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data);
|
2010-10-19 15:35:46 +00:00
|
|
|
setlinestyle(0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Draw Selected Faces */
|
2009-01-31 13:30:56 +00:00
|
|
|
if(me->drawflag & ME_DRAWFACES) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2010-10-19 15:35:46 +00:00
|
|
|
/* dull unselected faces so as not to get in the way of seeing color */
|
|
|
|
|
glColor4ub(96, 96, 96, 64);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedFacesTex(dm, draw_mesh_face_select__drawFaceOptsInv, (void*)me);
|
2010-10-19 15:35:46 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Draw Stippled Outline for selected faces */
|
|
|
|
|
glColor3ub(255, 255, 255);
|
|
|
|
|
setlinestyle(1);
|
2011-08-12 18:13:55 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data);
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
BLI_edgehash_free(data.eh, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 18:13:55 +00:00
|
|
|
/***************************** Texture Drawing ******************************/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
static Material *give_current_material_or_def(Object *ob, int matnr)
|
|
|
|
|
{
|
|
|
|
|
extern Material defmaterial; // render module abuse...
|
|
|
|
|
Material *ma= give_current_material(ob, matnr);
|
|
|
|
|
|
|
|
|
|
return ma?ma:&defmaterial;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int set_draw_settings_cached(int clearcache, int textured, MTFace *texface, int lit, Object *litob, int litmatnr, int doublesided)
|
|
|
|
|
{
|
|
|
|
|
static int c_textured;
|
|
|
|
|
static int c_lit;
|
|
|
|
|
static int c_doublesided;
|
|
|
|
|
static MTFace *c_texface;
|
|
|
|
|
static Object *c_litob;
|
|
|
|
|
static int c_litmatnr;
|
|
|
|
|
static int c_badtex;
|
|
|
|
|
|
|
|
|
|
if (clearcache) {
|
|
|
|
|
c_textured= c_lit= c_doublesided= -1;
|
|
|
|
|
c_texface= (MTFace*) -1;
|
|
|
|
|
c_litob= (Object*) -1;
|
|
|
|
|
c_litmatnr= -1;
|
|
|
|
|
c_badtex= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (texface) {
|
|
|
|
|
lit = lit && (lit==-1 || texface->mode&TF_LIGHT);
|
|
|
|
|
textured = textured && (texface->mode&TF_TEX);
|
|
|
|
|
doublesided = texface->mode&TF_TWOSIDE;
|
|
|
|
|
} else {
|
|
|
|
|
textured = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (doublesided!=c_doublesided) {
|
|
|
|
|
if (doublesided) glDisable(GL_CULL_FACE);
|
|
|
|
|
else glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
|
|
c_doublesided= doublesided;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (textured!=c_textured || texface!=c_texface) {
|
|
|
|
|
if (textured ) {
|
2009-08-16 20:14:49 +00:00
|
|
|
c_badtex= !GPU_set_tpage(texface, !(litob->mode & OB_MODE_TEXTURE_PAINT));
|
2008-12-19 12:14:58 +00:00
|
|
|
} else {
|
2009-08-16 20:14:49 +00:00
|
|
|
GPU_set_tpage(NULL, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
c_badtex= 0;
|
|
|
|
|
}
|
|
|
|
|
c_textured= textured;
|
|
|
|
|
c_texface= texface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c_badtex) lit= 0;
|
|
|
|
|
if (lit!=c_lit || litob!=c_litob || litmatnr!=c_litmatnr) {
|
|
|
|
|
if (lit) {
|
|
|
|
|
Material *ma= give_current_material_or_def(litob, litmatnr+1);
|
|
|
|
|
float spec[4];
|
|
|
|
|
|
|
|
|
|
spec[0]= ma->spec*ma->specr;
|
|
|
|
|
spec[1]= ma->spec*ma->specg;
|
|
|
|
|
spec[2]= ma->spec*ma->specb;
|
|
|
|
|
spec[3]= 1.0;
|
|
|
|
|
|
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
|
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
2011-03-25 13:37:50 +00:00
|
|
|
glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(ma->har, 0, 128));
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
|
}
|
|
|
|
|
c_lit= lit;
|
|
|
|
|
c_litob= litob;
|
|
|
|
|
c_litmatnr= litmatnr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c_badtex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Icky globals, fix with userdata parameter */
|
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static struct TextureDrawState {
|
2008-12-19 12:14:58 +00:00
|
|
|
Object *ob;
|
|
|
|
|
int islit, istex;
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
int color_profile;
|
2008-12-19 12:14:58 +00:00
|
|
|
unsigned char obcol[4];
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
} Gtexdraw = {NULL, 0, 0, 0, {0, 0, 0, 0}};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
unsigned char obcol[4];
|
|
|
|
|
int istex, solidtex= 0;
|
|
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
// XXX scene->obedit warning
|
2009-10-11 19:06:38 +00:00
|
|
|
if(v3d->drawtype==OB_SOLID || ((ob->mode & OB_MODE_EDIT) && v3d->drawtype!=OB_TEXTURE)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw with default lights in solid draw mode and edit mode */
|
|
|
|
|
solidtex= 1;
|
|
|
|
|
Gtexdraw.islit= -1;
|
|
|
|
|
}
|
2009-02-06 19:21:24 +00:00
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw with lights in the scene otherwise */
|
2011-05-18 17:52:26 +00:00
|
|
|
Gtexdraw.islit= GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp);
|
2009-02-06 19:21:24 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255);
|
|
|
|
|
obcol[1]= CLAMPIS(ob->col[1]*255, 0, 255);
|
|
|
|
|
obcol[2]= CLAMPIS(ob->col[2]*255, 0, 255);
|
|
|
|
|
obcol[3]= CLAMPIS(ob->col[3]*255, 0, 255);
|
|
|
|
|
|
|
|
|
|
glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
|
|
|
|
|
if(solidtex || v3d->drawtype==OB_TEXTURE) istex= 1;
|
|
|
|
|
else istex= 0;
|
|
|
|
|
|
|
|
|
|
Gtexdraw.ob = ob;
|
|
|
|
|
Gtexdraw.istex = istex;
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
Gtexdraw.color_profile = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
|
2008-12-19 12:14:58 +00:00
|
|
|
memcpy(Gtexdraw.obcol, obcol, sizeof(obcol));
|
2011-03-03 17:59:04 +00:00
|
|
|
set_draw_settings_cached(1, 0, NULL, Gtexdraw.islit, NULL, 0, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static void draw_textured_end(void)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
/* switch off textures */
|
2009-08-16 20:14:49 +00:00
|
|
|
GPU_set_tpage(NULL, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
|
|
/* XXX, bad patch - GPU_default_lights() calls
|
|
|
|
|
* glLightfv(GL_LIGHT_POSITION, ...) which
|
|
|
|
|
* is transformed by the current matrix... we
|
|
|
|
|
* need to make sure that matrix is identity.
|
|
|
|
|
*
|
|
|
|
|
* It would be better if drawmesh.c kept track
|
|
|
|
|
* of and restored the light settings it changed.
|
|
|
|
|
* - zr
|
|
|
|
|
*/
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glLoadIdentity();
|
|
|
|
|
GPU_default_lights();
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
static int draw_tface__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
if (tface && (tface->mode&TF_INVISIBLE)) return 0;
|
|
|
|
|
|
|
|
|
|
if (tface && set_draw_settings_cached(0, Gtexdraw.istex, tface, Gtexdraw.islit, Gtexdraw.ob, matnr, TF_TWOSIDE)) {
|
|
|
|
|
glColor3ub(0xFF, 0x00, 0xFF);
|
|
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
} else if (tface && tface->mode&TF_OBCOL) {
|
|
|
|
|
glColor3ubv(Gtexdraw.obcol);
|
|
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
} else if (!mcol) {
|
|
|
|
|
if (tface) glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
else {
|
|
|
|
|
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
if(ma) {
|
|
|
|
|
float col[3];
|
|
|
|
|
if(Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
|
|
|
|
|
else copy_v3_v3(col, &ma->r);
|
|
|
|
|
|
|
|
|
|
glColor3fv(col);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else glColor3f(1.0, 1.0, 1.0);
|
|
|
|
|
}
|
|
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
} else {
|
|
|
|
|
return 1; /* Set color from mcol */
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-03 15:35:01 +00:00
|
|
|
static int draw_tface__set_draw(MTFace *tface, MCol *mcol, int matnr)
|
|
|
|
|
{
|
|
|
|
|
if (tface && (tface->mode&TF_INVISIBLE)) return 0;
|
|
|
|
|
|
|
|
|
|
if (tface && set_draw_settings_cached(0, Gtexdraw.istex, tface, Gtexdraw.islit, Gtexdraw.ob, matnr, TF_TWOSIDE)) {
|
|
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
} else if (tface && tface->mode&TF_OBCOL) {
|
|
|
|
|
return 2; /* Don't set color */
|
|
|
|
|
} else if (!mcol) {
|
2010-06-23 16:35:42 +00:00
|
|
|
return 1; /* Don't set color */
|
2009-10-03 15:35:01 +00:00
|
|
|
} else {
|
|
|
|
|
return 1; /* Set color from mcol */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void add_tface_color_layer(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
MTFace *tface = DM_get_face_data_layer(dm, CD_MTFACE);
|
|
|
|
|
MFace *mface = DM_get_face_data_layer(dm, CD_MFACE);
|
|
|
|
|
MCol *finalCol;
|
|
|
|
|
int i,j;
|
|
|
|
|
MCol *mcol = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL);
|
|
|
|
|
if(!mcol)
|
|
|
|
|
mcol = dm->getFaceDataArray(dm, CD_MCOL);
|
|
|
|
|
|
|
|
|
|
finalCol = MEM_mallocN(sizeof(MCol)*4*dm->getNumFaces(dm),"add_tface_color_layer");
|
|
|
|
|
for(i=0;i<dm->getNumFaces(dm);i++) {
|
|
|
|
|
if (tface && (tface->mode&TF_INVISIBLE)) {
|
|
|
|
|
if( mcol )
|
|
|
|
|
memcpy(&finalCol[i*4],&mcol[i*4],sizeof(MCol)*4);
|
|
|
|
|
else
|
|
|
|
|
for(j=0;j<4;j++) {
|
|
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 255;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (tface && mface && set_draw_settings_cached(0, Gtexdraw.istex, tface, Gtexdraw.islit, Gtexdraw.ob, mface[i].mat_nr, TF_TWOSIDE)) {
|
|
|
|
|
for(j=0;j<4;j++) {
|
|
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 0;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
} else if (tface && tface->mode&TF_OBCOL) {
|
|
|
|
|
for(j=0;j<4;j++) {
|
2010-06-23 16:35:42 +00:00
|
|
|
finalCol[i*4+j].r = FTOCHAR(Gtexdraw.obcol[0]);
|
|
|
|
|
finalCol[i*4+j].g = FTOCHAR(Gtexdraw.obcol[1]);
|
|
|
|
|
finalCol[i*4+j].b = FTOCHAR(Gtexdraw.obcol[2]);
|
2009-10-03 15:35:01 +00:00
|
|
|
}
|
|
|
|
|
} else if (!mcol) {
|
|
|
|
|
if (tface) {
|
|
|
|
|
for(j=0;j<4;j++) {
|
|
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 255;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
float col[3];
|
2009-10-03 15:35:01 +00:00
|
|
|
Material *ma= give_current_material(Gtexdraw.ob, mface[i].mat_nr+1);
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
|
|
|
|
|
if(ma) {
|
|
|
|
|
if(Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r);
|
|
|
|
|
else copy_v3_v3(col, &ma->r);
|
|
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
for(j=0;j<4;j++) {
|
2010-06-23 16:35:42 +00:00
|
|
|
finalCol[i*4+j].b = FTOCHAR(col[2]);
|
|
|
|
|
finalCol[i*4+j].g = FTOCHAR(col[1]);
|
|
|
|
|
finalCol[i*4+j].r = FTOCHAR(col[0]);
|
2009-10-03 15:35:01 +00:00
|
|
|
}
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
}
|
2009-10-03 15:35:01 +00:00
|
|
|
else
|
|
|
|
|
for(j=0;j<4;j++) {
|
|
|
|
|
finalCol[i*4+j].b = 255;
|
|
|
|
|
finalCol[i*4+j].g = 255;
|
|
|
|
|
finalCol[i*4+j].r = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for(j=0;j<4;j++) {
|
|
|
|
|
finalCol[i*4+j].b = mcol[i*4+j].r;
|
|
|
|
|
finalCol[i*4+j].g = mcol[i*4+j].g;
|
|
|
|
|
finalCol[i*4+j].r = mcol[i*4+j].b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CustomData_add_layer( &dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numFaceData );
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
static int draw_tface_mapped__set_draw(void *userData, int index)
|
|
|
|
|
{
|
|
|
|
|
Mesh *me = (Mesh*)userData;
|
|
|
|
|
MTFace *tface = (me->mtface)? &me->mtface[index]: NULL;
|
2010-12-07 01:30:14 +00:00
|
|
|
MFace *mface = &me->mface[index];
|
2008-12-19 12:14:58 +00:00
|
|
|
MCol *mcol = (me->mcol)? &me->mcol[index]: NULL;
|
2010-12-07 01:30:14 +00:00
|
|
|
const int matnr = mface->mat_nr;
|
|
|
|
|
if (mface->flag & ME_HIDE) return 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
return draw_tface__set_draw(tface, mcol, matnr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int draw_em_tf_mapped__set_draw(void *userData, int index)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = userData;
|
2008-12-30 13:16:14 +00:00
|
|
|
EditFace *efa= EM_get_face_for_index(index);
|
2008-12-19 12:14:58 +00:00
|
|
|
MTFace *tface;
|
|
|
|
|
MCol *mcol;
|
|
|
|
|
int matnr;
|
|
|
|
|
|
2010-10-05 11:16:07 +00:00
|
|
|
if (efa->h)
|
2008-12-19 12:14:58 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
|
|
|
|
mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
|
|
|
|
|
matnr = efa->mat_nr;
|
|
|
|
|
|
2010-06-23 16:35:42 +00:00
|
|
|
return draw_tface__set_draw_legacy(tface, mcol, matnr);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r)
|
|
|
|
|
{
|
|
|
|
|
Mesh *me = (Mesh*)userData;
|
2010-10-07 10:04:07 +00:00
|
|
|
|
|
|
|
|
if ( (me->mface && me->mface[index].flag & ME_HIDE) ||
|
|
|
|
|
(me->mtface && (me->mtface[index].mode & TF_INVISIBLE))
|
|
|
|
|
) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
*drawSmooth_r = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
DerivedMesh *ddm;
|
|
|
|
|
MFace *mf, *mface= me->mface;
|
|
|
|
|
MTFace *tface= me->mtface;
|
|
|
|
|
MCol *mcol= me->mcol; /* why does mcol exist? */
|
|
|
|
|
bProperty *prop = get_ob_property(ob, "Text");
|
|
|
|
|
GPUVertexAttribs gattribs;
|
|
|
|
|
int a, totface= me->totface;
|
|
|
|
|
|
|
|
|
|
/* don't draw without tfaces */
|
|
|
|
|
if(!tface)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* don't draw when editing */
|
2009-10-11 19:06:38 +00:00
|
|
|
if(ob->mode & OB_MODE_EDIT)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
else if(ob==OBACT)
|
2011-07-20 15:56:35 +00:00
|
|
|
if(paint_facesel_test(ob) || paint_vertsel_test(ob))
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
for(a=0, mf=mface; a<totface; a++, tface++, mf++) {
|
|
|
|
|
int mode= tface->mode;
|
|
|
|
|
int matnr= mf->mat_nr;
|
|
|
|
|
int mf_smooth= mf->flag & ME_SMOOTH;
|
|
|
|
|
|
|
|
|
|
if (!(mf->flag&ME_HIDE) && !(mode&TF_INVISIBLE) && (mode&TF_BMFONT)) {
|
|
|
|
|
float v1[3], v2[3], v3[3], v4[3];
|
|
|
|
|
char string[MAX_PROPSTRING];
|
|
|
|
|
int characters, i, glattrib= -1, badtex= 0;
|
|
|
|
|
|
|
|
|
|
if(glsl) {
|
|
|
|
|
GPU_enable_material(matnr+1, &gattribs);
|
|
|
|
|
|
|
|
|
|
for(i=0; i<gattribs.totlayer; i++) {
|
|
|
|
|
if(gattribs.layer[i].type == CD_MTFACE) {
|
|
|
|
|
glattrib = gattribs.layer[i].glindex;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
badtex = set_draw_settings_cached(0, Gtexdraw.istex, tface, Gtexdraw.islit, Gtexdraw.ob, matnr, TF_TWOSIDE);
|
|
|
|
|
if (badtex) {
|
|
|
|
|
if (mcol) mcol+=4;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ddm->getVertCo(ddm, mf->v1, v1);
|
|
|
|
|
ddm->getVertCo(ddm, mf->v2, v2);
|
|
|
|
|
ddm->getVertCo(ddm, mf->v3, v3);
|
|
|
|
|
if (mf->v4) ddm->getVertCo(ddm, mf->v4, v4);
|
|
|
|
|
|
|
|
|
|
// The BM_FONT handling is in the gpu module, shared with the
|
|
|
|
|
// game engine, was duplicated previously
|
|
|
|
|
|
|
|
|
|
set_property_valstr(prop, string);
|
|
|
|
|
characters = strlen(string);
|
|
|
|
|
|
|
|
|
|
if(!BKE_image_get_ibuf(tface->tpage, NULL))
|
|
|
|
|
characters = 0;
|
|
|
|
|
|
|
|
|
|
if (!mf_smooth) {
|
|
|
|
|
float nor[3];
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_tri_v3( nor,v1, v2, v3);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glNormal3fv(nor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_render_text(tface, tface->mode, string, characters,
|
|
|
|
|
(unsigned int*)mcol, v1, v2, v3, (mf->v4? v4: NULL), glattrib);
|
|
|
|
|
}
|
|
|
|
|
if (mcol) {
|
|
|
|
|
mcol+=4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ddm->release(ddm);
|
|
|
|
|
}
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int faceselect)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
|
|
|
|
|
/* correct for negative scale */
|
|
|
|
|
if(ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
|
|
|
|
|
else glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
/* draw the textured mesh */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
draw_textured_begin(scene, v3d, rv3d, ob);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-11-25 21:59:12 +00:00
|
|
|
glColor4f(1.0f,1.0f,1.0f,1.0f);
|
|
|
|
|
|
2009-10-11 19:06:38 +00:00
|
|
|
if(ob->mode & OB_MODE_EDIT) {
|
2008-12-31 17:11:42 +00:00
|
|
|
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh);
|
2011-08-12 18:13:55 +00:00
|
|
|
}
|
|
|
|
|
else if(faceselect) {
|
2009-08-15 21:46:25 +00:00
|
|
|
if(ob->mode & OB_MODE_WEIGHT_PAINT)
|
2011-08-29 16:07:44 +00:00
|
|
|
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2010-12-07 01:30:14 +00:00
|
|
|
dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, me);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-02-19 23:53:40 +00:00
|
|
|
else {
|
2011-08-12 18:13:55 +00:00
|
|
|
if(GPU_buffer_legacy(dm)) {
|
2009-10-03 15:35:01 +00:00
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw_legacy);
|
2011-08-12 18:13:55 +00:00
|
|
|
}
|
2009-10-03 15:35:01 +00:00
|
|
|
else {
|
2011-08-12 18:13:55 +00:00
|
|
|
if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL))
|
2009-10-03 15:35:01 +00:00
|
|
|
add_tface_color_layer(dm);
|
2011-08-12 18:13:55 +00:00
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
dm->drawFacesTex(dm, draw_tface__set_draw);
|
|
|
|
|
}
|
2009-02-19 23:53:40 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw game engine text hack */
|
|
|
|
|
if(get_ob_property(ob, "Text"))
|
2008-12-22 09:43:29 +00:00
|
|
|
draw_mesh_text(scene, ob, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
draw_textured_end();
|
|
|
|
|
|
|
|
|
|
/* draw edges and selected faces over textured mesh */
|
2009-02-19 23:53:40 +00:00
|
|
|
if(!(ob == scene->obedit) && faceselect)
|
2011-08-12 18:13:55 +00:00
|
|
|
draw_mesh_face_select(rv3d, me, dm);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* reset from negative scale correction */
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
|
|
|
|
|
/* in editmode, the blend mode needs to be set incase it was ADD */
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
}
|
|
|
|
|
|