2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-19 12:14:58 +00:00
|
|
|
* ***** 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 recode and added functions
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_view3d/drawobject.c
|
|
|
|
|
* \ingroup spview3d
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
2012-07-08 20:36:00 +00:00
|
|
|
#include "DNA_constraint_types.h" /* for drawing constraint */
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
|
#include "DNA_material_types.h"
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_meta_types.h"
|
2013-03-31 19:52:37 +00:00
|
|
|
#include "DNA_rigidbody_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2009-07-30 15:00:26 +00:00
|
|
|
#include "DNA_smoke_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_world_types.h"
|
2012-04-30 08:24:44 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
|
#include "BLI_link_utils.h"
|
|
|
|
|
#include "BLI_string.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2014-04-17 15:14:07 +10:00
|
|
|
#include "BLI_memarena.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
#include "BKE_anim.h" /* for the where_on_path function */
|
2012-03-22 13:27:24 +00:00
|
|
|
#include "BKE_armature.h"
|
2011-11-05 13:00:39 +00:00
|
|
|
#include "BKE_camera.h"
|
2015-03-25 20:08:12 +01:00
|
|
|
#include "BKE_colortools.h"
|
2012-07-08 20:36:00 +00:00
|
|
|
#include "BKE_constraint.h" /* for the get_constraint_target function */
|
2011-09-14 00:37:27 +00:00
|
|
|
#include "BKE_curve.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_deform.h"
|
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
#include "BKE_font.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_key.h"
|
|
|
|
|
#include "BKE_lattice.h"
|
2013-12-26 17:24:42 +06:00
|
|
|
#include "BKE_main.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_material.h"
|
|
|
|
|
#include "BKE_mball.h"
|
|
|
|
|
#include "BKE_modifier.h"
|
2014-02-26 19:40:04 +06:00
|
|
|
#include "BKE_movieclip.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_object.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_particle.h"
|
2009-08-29 15:20:36 +00:00
|
|
|
#include "BKE_pointcache.h"
|
2011-11-06 06:08:18 +00:00
|
|
|
#include "BKE_scene.h"
|
2015-08-05 15:11:50 +02:00
|
|
|
#include "BKE_subsurf.h"
|
2009-08-16 11:16:04 +00:00
|
|
|
#include "BKE_unit.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "BKE_tracking.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
#include "GPU_draw.h"
|
2014-07-23 15:24:07 +02:00
|
|
|
#include "GPU_select.h"
|
2015-12-05 22:11:31 +01:00
|
|
|
#include "GPU_basic_shader.h"
|
2015-12-06 21:20:19 +01:00
|
|
|
#include "GPU_shader.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-30 13:16:14 +00:00
|
|
|
#include "ED_mesh.h"
|
2009-05-18 16:42:34 +00:00
|
|
|
#include "ED_particle.h"
|
|
|
|
|
#include "ED_screen.h"
|
2009-10-27 19:53:34 +00:00
|
|
|
#include "ED_sculpt.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "ED_types.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
2013-01-22 11:18:41 +00:00
|
|
|
#include "UI_interface_icons.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
2009-05-05 23:10:32 +00:00
|
|
|
#include "BLF_api.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-10-10 03:13:02 +00:00
|
|
|
#include "view3d_intern.h" /* bad level include */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-02-12 14:06:13 +06:00
|
|
|
/* Workaround for sequencer scene render mode.
|
|
|
|
|
*
|
|
|
|
|
* Strips doesn't use DAG to update objects or so, which
|
|
|
|
|
* might lead to situations when object is drawing without
|
|
|
|
|
* curve cache ready.
|
|
|
|
|
*
|
|
|
|
|
* Ideally we don't want to evaluate objects from drawing,
|
|
|
|
|
* but it'll require some major sequencer re-design. So
|
2014-08-13 09:33:46 +10:00
|
|
|
* for now just fallback to legacy behavior with calling
|
2014-02-12 14:06:13 +06:00
|
|
|
* display ist creating from draw().
|
|
|
|
|
*/
|
|
|
|
|
#define SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
|
2011-11-26 13:11:55 +00:00
|
|
|
typedef enum eWireDrawMode {
|
2012-03-25 23:54:33 +00:00
|
|
|
OBDRAW_WIRE_OFF = 0,
|
|
|
|
|
OBDRAW_WIRE_ON = 1,
|
|
|
|
|
OBDRAW_WIRE_ON_DEPTH = 2
|
2011-11-26 13:11:55 +00:00
|
|
|
} eWireDrawMode;
|
|
|
|
|
|
2011-12-20 08:47:36 +00:00
|
|
|
typedef struct drawDMVerts_userData {
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm;
|
2011-12-20 10:59:56 +00:00
|
|
|
|
|
|
|
|
BMVert *eve_act;
|
2013-06-11 05:56:02 +00:00
|
|
|
char sel;
|
2012-05-22 15:29:27 +00:00
|
|
|
|
|
|
|
|
/* cached theme values */
|
|
|
|
|
unsigned char th_editmesh_active[4];
|
|
|
|
|
unsigned char th_vertex_select[4];
|
|
|
|
|
unsigned char th_vertex[4];
|
|
|
|
|
unsigned char th_skin_root[4];
|
|
|
|
|
float th_vertex_size;
|
|
|
|
|
|
|
|
|
|
/* for skin node drawing */
|
2013-06-20 11:18:19 +00:00
|
|
|
int cd_vskin_offset;
|
2012-05-22 15:29:27 +00:00
|
|
|
float imat[4][4];
|
2011-12-20 08:47:36 +00:00
|
|
|
} drawDMVerts_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawDMEdgesSel_userData {
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm;
|
2011-12-20 10:59:56 +00:00
|
|
|
|
2011-12-20 08:47:36 +00:00
|
|
|
unsigned char *baseCol, *selCol, *actCol;
|
2011-12-20 10:59:56 +00:00
|
|
|
BMEdge *eed_act;
|
2011-12-20 08:47:36 +00:00
|
|
|
} drawDMEdgesSel_userData;
|
|
|
|
|
|
2014-06-04 20:40:42 +10:00
|
|
|
typedef struct drawDMEdgesSelInterp_userData {
|
|
|
|
|
BMesh *bm;
|
|
|
|
|
|
|
|
|
|
unsigned char *baseCol, *selCol;
|
|
|
|
|
unsigned char *lastCol;
|
|
|
|
|
} drawDMEdgesSelInterp_userData;
|
|
|
|
|
|
2014-06-19 04:01:19 +10:00
|
|
|
typedef struct drawDMEdgesWeightInterp_userData {
|
2014-06-19 04:17:38 +10:00
|
|
|
BMesh *bm;
|
|
|
|
|
|
2014-06-19 04:01:19 +10:00
|
|
|
int cd_dvert_offset;
|
|
|
|
|
int defgroup_tot;
|
|
|
|
|
int vgroup_index;
|
|
|
|
|
char weight_user;
|
|
|
|
|
float alert_color[3];
|
|
|
|
|
|
|
|
|
|
} drawDMEdgesWeightInterp_userData;
|
|
|
|
|
|
2011-12-20 08:47:36 +00:00
|
|
|
typedef struct drawDMFacesSel_userData {
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2011-12-27 22:12:46 +00:00
|
|
|
unsigned char *cols[4];
|
2012-12-20 07:57:26 +00:00
|
|
|
#else
|
|
|
|
|
unsigned char *cols[3];
|
|
|
|
|
#endif
|
2011-12-20 10:59:56 +00:00
|
|
|
|
2012-12-23 03:04:19 +00:00
|
|
|
DerivedMesh *dm;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm;
|
2011-12-20 10:59:56 +00:00
|
|
|
|
|
|
|
|
BMFace *efa_act;
|
2014-04-27 00:22:49 +10:00
|
|
|
const int *orig_index_mp_to_orig;
|
2011-12-20 08:47:36 +00:00
|
|
|
} drawDMFacesSel_userData;
|
|
|
|
|
|
2012-01-24 19:57:34 +00:00
|
|
|
typedef struct drawDMNormal_userData {
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm;
|
2012-05-01 11:01:24 +00:00
|
|
|
int uniform_scale;
|
2012-01-24 19:57:34 +00:00
|
|
|
float normalsize;
|
2012-05-01 11:01:24 +00:00
|
|
|
float tmat[3][3];
|
|
|
|
|
float imat[3][3];
|
2012-01-24 19:57:34 +00:00
|
|
|
} drawDMNormal_userData;
|
|
|
|
|
|
2014-06-19 18:36:49 +10:00
|
|
|
typedef struct drawMVertOffset_userData {
|
2011-12-20 08:47:36 +00:00
|
|
|
MVert *mvert;
|
2014-06-19 18:36:49 +10:00
|
|
|
int offset;
|
|
|
|
|
} drawMVertOffset_userData;
|
2011-12-20 08:47:36 +00:00
|
|
|
|
2013-06-20 11:18:19 +00:00
|
|
|
typedef struct drawDMLayer_userData {
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm;
|
2013-06-20 11:18:19 +00:00
|
|
|
int cd_layer_offset;
|
|
|
|
|
} drawDMLayer_userData;
|
|
|
|
|
|
2014-06-19 18:36:49 +10:00
|
|
|
typedef struct drawBMOffset_userData {
|
|
|
|
|
BMesh *bm;
|
|
|
|
|
int offset;
|
|
|
|
|
} drawBMOffset_userData;
|
|
|
|
|
|
|
|
|
|
typedef struct drawBMSelect_userData {
|
|
|
|
|
BMesh *bm;
|
|
|
|
|
bool select;
|
|
|
|
|
} drawBMSelect_userData;
|
|
|
|
|
|
2014-01-13 16:33:18 +06:00
|
|
|
static void draw_bounding_volume(Object *ob, char type);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
static void drawcube_size(float size);
|
|
|
|
|
static void drawcircle_size(float size);
|
|
|
|
|
static void draw_empty_sphere(float size);
|
|
|
|
|
static void draw_empty_cone(float size);
|
2015-04-18 12:28:19 +02:00
|
|
|
static void draw_box(float vec[8][3], bool solid);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
static void ob_wire_color_blend_theme_id(const unsigned char ob_wire_col[4], const int theme_id, float fac)
|
|
|
|
|
{
|
2012-08-17 12:32:13 +00:00
|
|
|
float col_wire[3], col_bg[3], col[3];
|
|
|
|
|
|
|
|
|
|
rgb_uchar_to_float(col_wire, ob_wire_col);
|
2012-08-16 18:37:30 +00:00
|
|
|
|
|
|
|
|
UI_GetThemeColor3fv(theme_id, col_bg);
|
|
|
|
|
interp_v3_v3v3(col, col_bg, col_wire, fac);
|
|
|
|
|
glColor3fv(col);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-03 14:08:04 +00:00
|
|
|
/* this condition has been made more complex since editmode can draw textures */
|
2014-02-05 23:42:11 +06:00
|
|
|
bool check_object_draw_texture(Scene *scene, View3D *v3d, const char drawtype)
|
2012-04-03 14:08:04 +00:00
|
|
|
{
|
|
|
|
|
/* texture and material draw modes */
|
2013-01-22 13:35:02 +00:00
|
|
|
if (ELEM(v3d->drawtype, OB_TEXTURE, OB_MATERIAL) && drawtype > OB_SOLID) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-04-03 14:08:04 +00:00
|
|
|
|
|
|
|
|
/* textured solid */
|
2013-01-22 13:35:02 +00:00
|
|
|
if ((v3d->drawtype == OB_SOLID) &&
|
|
|
|
|
(v3d->flag2 & V3D_SOLID_TEX) &&
|
|
|
|
|
(BKE_scene_use_new_shading_nodes(scene) == false))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-04-03 14:08:04 +00:00
|
|
|
|
2013-01-22 13:35:02 +00:00
|
|
|
if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-01-22 12:36:06 +00:00
|
|
|
|
2013-01-22 13:35:02 +00:00
|
|
|
return false;
|
2012-04-03 14:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 00:42:44 +00:00
|
|
|
static bool check_object_draw_editweight(Mesh *me, DerivedMesh *finalDM)
|
|
|
|
|
{
|
|
|
|
|
if (me->drawflag & ME_DRAWEIGHT) {
|
|
|
|
|
/* editmesh handles its own weight drawing */
|
|
|
|
|
if (finalDM->type != DM_TYPE_EDITBMESH) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
|
2010-05-08 17:54:29 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2010-05-08 17:54:29 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (G.f & G_BACKBUFSEL)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2010-05-08 17:54:29 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if ((vd->flag & V3D_ZBUF_SELECT) == 0)
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2010-05-08 17:54:29 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* if its drawing textures with zbuf sel, then don't draw dots */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt == OB_TEXTURE && vd->drawtype == OB_TEXTURE)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2010-05-08 17:54:29 +00:00
|
|
|
|
2012-03-10 22:00:55 +00:00
|
|
|
if ((vd->drawtype >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX))
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2010-05-08 17:54:29 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2010-05-08 17:54:29 +00:00
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
|
|
|
|
|
/* ************************ */
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* check for glsl drawing */
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
bool draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (G.f & G_PICKSEL)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2012-04-03 14:08:04 +00:00
|
|
|
if (!check_object_draw_texture(scene, v3d, dt))
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT))
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP)
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2015-05-17 17:25:57 +02:00
|
|
|
if (v3d->drawtype == OB_TEXTURE)
|
|
|
|
|
return (scene->gm.matmode == GAME_MAT_GLSL && !BKE_scene_use_new_shading_nodes(scene));
|
|
|
|
|
else if (v3d->drawtype == OB_MATERIAL && dt > OB_SOLID)
|
|
|
|
|
return true;
|
|
|
|
|
else
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
static bool check_alpha_pass(Base *base)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (base->flag & OB_FROMDUPLI)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (G.f & G_PICKSEL)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2012-12-03 16:19:38 +00:00
|
|
|
|
|
|
|
|
if (base->object->mode & OB_MODE_ALL_PAINT)
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2012-12-03 16:19:38 +00:00
|
|
|
|
2011-12-07 22:03:49 +00:00
|
|
|
return (base->object->dtx & OB_DRAWTRANSP);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
/***/
|
2013-04-20 05:50:22 +00:00
|
|
|
static const unsigned int colortab[] = {
|
|
|
|
|
0x0, 0x403000, 0xFFFF88
|
2012-11-03 15:35:03 +00:00
|
|
|
};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* ----------------- OpenGL Circle Drawing - Tables for Optimized Drawing Speed ------------------ */
|
2008-12-19 12:14:58 +00:00
|
|
|
/* 32 values of sin function (still same result!) */
|
2011-09-17 05:35:55 +00:00
|
|
|
#define CIRCLE_RESOL 32
|
|
|
|
|
|
2011-09-17 06:18:35 +00:00
|
|
|
static const float sinval[CIRCLE_RESOL] = {
|
2008-12-19 12:14:58 +00:00
|
|
|
0.00000000,
|
|
|
|
|
0.20129852,
|
|
|
|
|
0.39435585,
|
|
|
|
|
0.57126821,
|
|
|
|
|
0.72479278,
|
|
|
|
|
0.84864425,
|
|
|
|
|
0.93775213,
|
|
|
|
|
0.98846832,
|
|
|
|
|
0.99871650,
|
|
|
|
|
0.96807711,
|
|
|
|
|
0.89780453,
|
|
|
|
|
0.79077573,
|
|
|
|
|
0.65137248,
|
|
|
|
|
0.48530196,
|
|
|
|
|
0.29936312,
|
|
|
|
|
0.10116832,
|
|
|
|
|
-0.10116832,
|
|
|
|
|
-0.29936312,
|
|
|
|
|
-0.48530196,
|
|
|
|
|
-0.65137248,
|
|
|
|
|
-0.79077573,
|
|
|
|
|
-0.89780453,
|
|
|
|
|
-0.96807711,
|
|
|
|
|
-0.99871650,
|
|
|
|
|
-0.98846832,
|
|
|
|
|
-0.93775213,
|
|
|
|
|
-0.84864425,
|
|
|
|
|
-0.72479278,
|
|
|
|
|
-0.57126821,
|
|
|
|
|
-0.39435585,
|
|
|
|
|
-0.20129852,
|
|
|
|
|
0.00000000
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* 32 values of cos function (still same result!) */
|
2011-09-17 06:18:35 +00:00
|
|
|
static const float cosval[CIRCLE_RESOL] = {
|
2008-12-19 12:14:58 +00:00
|
|
|
1.00000000,
|
|
|
|
|
0.97952994,
|
|
|
|
|
0.91895781,
|
|
|
|
|
0.82076344,
|
|
|
|
|
0.68896691,
|
|
|
|
|
0.52896401,
|
|
|
|
|
0.34730525,
|
|
|
|
|
0.15142777,
|
|
|
|
|
-0.05064916,
|
|
|
|
|
-0.25065253,
|
|
|
|
|
-0.44039415,
|
|
|
|
|
-0.61210598,
|
|
|
|
|
-0.75875812,
|
|
|
|
|
-0.87434661,
|
|
|
|
|
-0.95413925,
|
|
|
|
|
-0.99486932,
|
|
|
|
|
-0.99486932,
|
|
|
|
|
-0.95413925,
|
|
|
|
|
-0.87434661,
|
|
|
|
|
-0.75875812,
|
|
|
|
|
-0.61210598,
|
|
|
|
|
-0.44039415,
|
|
|
|
|
-0.25065253,
|
|
|
|
|
-0.05064916,
|
|
|
|
|
0.15142777,
|
|
|
|
|
0.34730525,
|
|
|
|
|
0.52896401,
|
|
|
|
|
0.68896691,
|
|
|
|
|
0.82076344,
|
|
|
|
|
0.91895781,
|
|
|
|
|
0.97952994,
|
|
|
|
|
1.00000000
|
|
|
|
|
};
|
|
|
|
|
|
2010-12-03 23:55:10 +00:00
|
|
|
static void draw_xyz_wire(const float c[3], float size, int axis)
|
2010-04-02 05:05:49 +00:00
|
|
|
{
|
2015-04-13 16:56:43 -04:00
|
|
|
float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3] = {0.0f, 0.0f, 0.0f};
|
2011-03-27 15:57:27 +00:00
|
|
|
float dim = size * 0.1f;
|
2010-11-03 06:31:53 +00:00
|
|
|
float dx[3], dy[3], dz[3];
|
|
|
|
|
|
2015-04-13 16:56:43 -04:00
|
|
|
dx[0] = dim; dx[1] = 0.0f; dx[2] = 0.0f;
|
|
|
|
|
dy[0] = 0.0f; dy[1] = dim; dy[2] = 0.0f;
|
|
|
|
|
dz[0] = 0.0f; dz[1] = 0.0f; dz[2] = dim;
|
2010-11-03 06:31:53 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (axis) {
|
|
|
|
|
case 0: /* x axis */
|
2010-04-02 05:05:49 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
|
|
|
|
/* bottom left to top right */
|
|
|
|
|
sub_v3_v3v3(v1, c, dx);
|
|
|
|
|
sub_v3_v3(v1, dy);
|
|
|
|
|
add_v3_v3v3(v2, c, dx);
|
|
|
|
|
add_v3_v3(v2, dy);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
|
|
|
|
|
/* top left to bottom right */
|
2015-04-13 16:56:43 -04:00
|
|
|
mul_v3_fl(dy, 2.0f);
|
2010-04-02 05:05:49 +00:00
|
|
|
add_v3_v3(v1, dy);
|
|
|
|
|
sub_v3_v3(v2, dy);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
break;
|
2012-03-25 23:54:33 +00:00
|
|
|
case 1: /* y axis */
|
2010-04-02 05:05:49 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
|
|
|
|
/* bottom left to top right */
|
|
|
|
|
mul_v3_fl(dx, 0.75f);
|
|
|
|
|
sub_v3_v3v3(v1, c, dx);
|
|
|
|
|
sub_v3_v3(v1, dy);
|
|
|
|
|
add_v3_v3v3(v2, c, dx);
|
|
|
|
|
add_v3_v3(v2, dy);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
|
|
|
|
|
/* top left to center */
|
2015-04-13 16:56:43 -04:00
|
|
|
mul_v3_fl(dy, 2.0f);
|
2010-04-02 05:05:49 +00:00
|
|
|
add_v3_v3(v1, dy);
|
|
|
|
|
copy_v3_v3(v2, c);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
break;
|
2012-03-25 23:54:33 +00:00
|
|
|
case 2: /* z axis */
|
2010-04-02 05:05:49 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
|
|
|
|
|
/* start at top left */
|
|
|
|
|
sub_v3_v3v3(v1, c, dx);
|
2010-07-28 08:05:39 +00:00
|
|
|
add_v3_v3v3(v1, c, dz);
|
2010-04-02 05:05:49 +00:00
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
|
2015-04-13 16:56:43 -04:00
|
|
|
mul_v3_fl(dx, 2.0f);
|
2010-04-02 05:05:49 +00:00
|
|
|
add_v3_v3(v1, dx);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
|
2015-04-13 16:56:43 -04:00
|
|
|
mul_v3_fl(dz, 2.0f);
|
2010-04-02 05:05:49 +00:00
|
|
|
sub_v3_v3(v1, dx);
|
2010-07-28 08:05:39 +00:00
|
|
|
sub_v3_v3(v1, dz);
|
2010-04-02 05:05:49 +00:00
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
|
|
|
|
|
add_v3_v3(v1, dx);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
void drawaxes(float size, char drawtype)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
int axis;
|
2012-03-25 23:54:33 +00:00
|
|
|
float v1[3] = {0.0, 0.0, 0.0};
|
|
|
|
|
float v2[3] = {0.0, 0.0, 0.0};
|
|
|
|
|
float v3[3] = {0.0, 0.0, 0.0};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (drawtype) {
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
case OB_PLAINAXES:
|
2012-03-25 23:54:33 +00:00
|
|
|
for (axis = 0; axis < 3; axis++) {
|
2012-03-18 06:01:33 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v1[axis] = size;
|
|
|
|
|
v2[axis] = -size;
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
|
|
|
|
|
/* reset v1 & v2 to zero */
|
2012-03-25 23:54:33 +00:00
|
|
|
v1[axis] = v2[axis] = 0.0f;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case OB_SINGLE_ARROW:
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glBegin(GL_LINES);
|
2012-03-18 06:01:33 +00:00
|
|
|
/* in positive z direction only */
|
2012-03-25 23:54:33 +00:00
|
|
|
v1[2] = size;
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
2012-03-18 06:01:33 +00:00
|
|
|
glEnd();
|
2010-12-03 23:55:10 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* square pyramid */
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v2[0] = size * 0.035f; v2[1] = size * 0.035f;
|
|
|
|
|
v3[0] = size * -0.035f; v3[1] = size * 0.035f;
|
|
|
|
|
v2[2] = v3[2] = size * 0.75f;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (axis = 0; axis < 4; axis++) {
|
2012-03-18 06:01:33 +00:00
|
|
|
if (axis % 2 == 1) {
|
|
|
|
|
v2[0] = -v2[0];
|
|
|
|
|
v3[1] = -v3[1];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
v2[1] = -v2[1];
|
|
|
|
|
v3[0] = -v3[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
glVertex3fv(v3);
|
2010-12-03 23:55:10 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
glEnd();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
|
|
|
|
case OB_CUBE:
|
|
|
|
|
drawcube_size(size);
|
|
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
case OB_CIRCLE:
|
|
|
|
|
drawcircle_size(size);
|
|
|
|
|
break;
|
2010-12-03 23:55:10 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
case OB_EMPTY_SPHERE:
|
|
|
|
|
draw_empty_sphere(size);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OB_EMPTY_CONE:
|
|
|
|
|
draw_empty_cone(size);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OB_ARROWS:
|
|
|
|
|
default:
|
|
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
for (axis = 0; axis < 3; axis++) {
|
|
|
|
|
const int arrow_axis = (axis == 0) ? 1 : 0;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v2[axis] = size;
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v1[axis] = size * 0.85f;
|
|
|
|
|
v1[arrow_axis] = -size * 0.08f;
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v1[arrow_axis] = size * 0.08f;
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
|
|
|
|
|
glEnd();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v2[axis] += size * 0.125f;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
draw_xyz_wire(v2, size, axis);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* reset v1 & v2 to zero */
|
2012-03-25 23:54:33 +00:00
|
|
|
v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* Function to draw an Image on an empty Object */
|
2012-08-16 18:37:30 +00:00
|
|
|
static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4])
|
2011-05-09 16:31:54 +00:00
|
|
|
{
|
2015-03-30 00:51:00 -04:00
|
|
|
Image *ima = ob->data;
|
2014-01-13 21:57:05 +01:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, ob->iuser, NULL);
|
2011-05-09 16:31:54 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ibuf && (ibuf->rect == NULL) && (ibuf->rect_float != NULL)) {
|
2011-05-09 16:31:54 +00:00
|
|
|
IMB_rect_from_float(ibuf);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
int ima_x, ima_y;
|
|
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
/* Get the buffer dimensions so we can fallback to fake ones */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ibuf && ibuf->rect) {
|
2012-03-25 23:54:33 +00:00
|
|
|
ima_x = ibuf->x;
|
|
|
|
|
ima_y = ibuf->y;
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
ima_x = 1;
|
|
|
|
|
ima_y = 1;
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
float sca_x = 1.0f;
|
|
|
|
|
float sca_y = 1.0f;
|
|
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
/* Get the image aspect even if the buffer is invalid */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ima) {
|
|
|
|
|
if (ima->aspx > ima->aspy) {
|
2012-03-25 23:54:33 +00:00
|
|
|
sca_y = ima->aspy / ima->aspx;
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (ima->aspx < ima->aspy) {
|
2012-03-25 23:54:33 +00:00
|
|
|
sca_x = ima->aspx / ima->aspy;
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* Calculate the scale center based on object's origin */
|
2015-12-16 01:24:15 -05:00
|
|
|
float ofs_x = ob->ima_ofs[0] * ima_x;
|
|
|
|
|
float ofs_y = ob->ima_ofs[1] * ima_y;
|
2011-05-09 16:31:54 +00:00
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
|
|
|
|
|
/* Calculate Image scale */
|
2015-12-16 01:24:15 -05:00
|
|
|
float scale = ob->empty_drawsize / max_ff((float)ima_x * sca_x, (float)ima_y * sca_y);
|
2011-05-09 16:31:54 +00:00
|
|
|
|
|
|
|
|
/* Set the object scale */
|
|
|
|
|
glScalef(scale * sca_x, scale * sca_y, 1.0f);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ibuf && ibuf->rect) {
|
2013-03-24 12:13:13 +00:00
|
|
|
const bool use_clip = (U.glalphaclip != 1.0f);
|
2014-01-12 22:27:55 +11:00
|
|
|
int zoomfilter = (U.gameflags & USER_DISABLE_MIPMAP ) ? GL_NEAREST : GL_LINEAR;
|
2011-05-09 16:31:54 +00:00
|
|
|
/* Setup GL params */
|
|
|
|
|
glEnable(GL_BLEND);
|
2015-12-16 01:24:15 -05:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2011-05-09 16:31:54 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (use_clip) {
|
|
|
|
|
glEnable(GL_ALPHA_TEST);
|
|
|
|
|
glAlphaFunc(GL_GREATER, U.glalphaclip);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
/* Use the object color and alpha */
|
|
|
|
|
glColor4fv(ob->col);
|
|
|
|
|
|
|
|
|
|
/* Draw the Image on the screen */
|
2013-11-18 11:26:37 +01:00
|
|
|
glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_RGBA, GL_UNSIGNED_BYTE, zoomfilter, ibuf->rect);
|
2011-05-09 16:31:54 +00:00
|
|
|
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
2013-03-24 12:13:13 +00:00
|
|
|
|
|
|
|
|
if (use_clip) {
|
|
|
|
|
glDisable(GL_ALPHA_TEST);
|
|
|
|
|
glAlphaFunc(GL_GREATER, 0.0f);
|
|
|
|
|
}
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2011-05-09 16:31:54 +00:00
|
|
|
|
2013-02-24 23:18:21 +00:00
|
|
|
/* Calculate the outline vertex positions */
|
|
|
|
|
glBegin(GL_LINE_LOOP);
|
|
|
|
|
glVertex2f(ofs_x, ofs_y);
|
|
|
|
|
glVertex2f(ofs_x + ima_x, ofs_y);
|
|
|
|
|
glVertex2f(ofs_x + ima_x, ofs_y + ima_y);
|
|
|
|
|
glVertex2f(ofs_x, ofs_y + ima_y);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
/* Reset GL settings */
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glPopMatrix();
|
2012-11-15 15:59:58 +00:00
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, const float tmat[4][4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-09-17 06:18:35 +00:00
|
|
|
float vx[3], vy[3];
|
2012-03-25 23:54:33 +00:00
|
|
|
float *viter = (float *)verts;
|
2010-07-31 10:58:10 +00:00
|
|
|
|
|
|
|
|
mul_v3_v3fl(vx, tmat[0], rad);
|
|
|
|
|
mul_v3_v3fl(vy, tmat[1], rad);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (unsigned int a = 0; a < CIRCLE_RESOL; a++, viter += 3) {
|
2012-03-25 23:54:33 +00:00
|
|
|
viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
|
|
|
|
|
viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
|
|
|
|
|
viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2011-09-17 06:18:35 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
void drawcircball(int mode, const float cent[3], float rad, const float tmat[4][4])
|
2011-09-17 06:18:35 +00:00
|
|
|
{
|
|
|
|
|
float verts[CIRCLE_RESOL][3];
|
|
|
|
|
|
|
|
|
|
circball_array_fill(verts, cent, rad, tmat);
|
|
|
|
|
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, verts);
|
|
|
|
|
glDrawArrays(mode, 0, CIRCLE_RESOL);
|
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* circle for object centers, special_color is for library or ob users */
|
2015-02-03 09:32:19 +11:00
|
|
|
static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], int selstate, bool special_color)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
const float size = ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f;
|
2011-09-17 06:18:35 +00:00
|
|
|
float verts[CIRCLE_RESOL][3];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-05-04 18:00:29 +02:00
|
|
|
/* using gldepthfunc guarantees that it does write z values,
|
|
|
|
|
* but not checks for it, so centers remain visible independent order of drawing */
|
|
|
|
|
if (v3d->zbuf) glDepthFunc(GL_ALWAYS);
|
|
|
|
|
/* write to near buffer always */
|
|
|
|
|
glDepthRange(0.0, 0.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (special_color) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (selstate == ACTIVE || selstate == SELECT) glColor4ub(0x88, 0xFF, 0xFF, 155);
|
2008-12-19 12:14:58 +00:00
|
|
|
else glColor4ub(0x55, 0xCC, 0xCC, 155);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (selstate == ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -80);
|
|
|
|
|
else if (selstate == SELECT) UI_ThemeColorShadeAlpha(TH_SELECT, 0, -80);
|
|
|
|
|
else if (selstate == DESELECT) UI_ThemeColorShadeAlpha(TH_TRANSFORM, 0, -80);
|
|
|
|
|
}
|
2011-09-17 06:18:35 +00:00
|
|
|
|
|
|
|
|
circball_array_fill(verts, co, size, rv3d->viewinv);
|
|
|
|
|
|
|
|
|
|
/* enable vertex array */
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, verts);
|
|
|
|
|
|
|
|
|
|
/* 1. draw filled, blended polygon */
|
|
|
|
|
glDrawArrays(GL_POLYGON, 0, CIRCLE_RESOL);
|
|
|
|
|
|
|
|
|
|
/* 2. draw outline */
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -30);
|
2011-09-17 06:18:35 +00:00
|
|
|
glDrawArrays(GL_LINE_LOOP, 0, CIRCLE_RESOL);
|
|
|
|
|
|
2012-03-03 11:45:08 +00:00
|
|
|
/* finish up */
|
2011-09-17 06:18:35 +00:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
|
2015-05-04 18:00:29 +02:00
|
|
|
glDepthRange(0.0, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_BLEND);
|
2011-09-17 06:18:35 +00:00
|
|
|
|
2015-05-04 18:00:29 +02:00
|
|
|
if (v3d->zbuf) glDepthFunc(GL_LEQUAL);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-19 18:45:31 +00:00
|
|
|
/* *********** text drawing for object/particles/armature ************* */
|
|
|
|
|
|
|
|
|
|
typedef struct ViewCachedString {
|
2014-04-17 15:14:07 +10:00
|
|
|
struct ViewCachedString *next;
|
2010-12-20 03:59:22 +00:00
|
|
|
float vec[3];
|
|
|
|
|
union {
|
|
|
|
|
unsigned char ub[4];
|
|
|
|
|
int pack;
|
|
|
|
|
} col;
|
2011-05-12 16:47:36 +00:00
|
|
|
short sco[2];
|
2009-05-18 16:42:34 +00:00
|
|
|
short xoffs;
|
2010-02-19 20:09:42 +00:00
|
|
|
short flag;
|
2014-06-15 04:06:44 +10:00
|
|
|
int str_len;
|
|
|
|
|
|
2010-10-30 23:02:38 +00:00
|
|
|
/* str is allocated past the end */
|
2014-06-15 04:06:44 +10:00
|
|
|
char str[0];
|
2009-09-19 18:45:31 +00:00
|
|
|
} ViewCachedString;
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
/* one arena for all 3 string lists */
|
|
|
|
|
static MemArena *g_v3d_strings_arena = NULL;
|
|
|
|
|
static ViewCachedString *g_v3d_strings[3] = {NULL, NULL, NULL};
|
|
|
|
|
static int g_v3d_string_level = -1;
|
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
void view3d_cached_text_draw_begin(void)
|
2009-09-19 18:45:31 +00:00
|
|
|
{
|
2014-04-17 15:14:07 +10:00
|
|
|
g_v3d_string_level++;
|
|
|
|
|
|
|
|
|
|
BLI_assert(g_v3d_string_level >= 0);
|
|
|
|
|
|
|
|
|
|
if (g_v3d_string_level == 0) {
|
|
|
|
|
BLI_assert(g_v3d_strings_arena == NULL);
|
|
|
|
|
}
|
2009-09-19 18:45:31 +00:00
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2011-12-03 20:49:41 +00:00
|
|
|
void view3d_cached_text_draw_add(const float co[3],
|
2014-04-17 15:14:07 +10:00
|
|
|
const char *str, const size_t str_len,
|
2011-12-03 20:49:41 +00:00
|
|
|
short xoffs, short flag,
|
|
|
|
|
const unsigned char col[4])
|
2009-05-18 16:42:34 +00:00
|
|
|
{
|
2014-04-17 15:14:07 +10:00
|
|
|
int alloc_len = str_len + 1;
|
|
|
|
|
ViewCachedString *vos;
|
|
|
|
|
|
|
|
|
|
BLI_assert(str_len == strlen(str));
|
|
|
|
|
|
|
|
|
|
if (g_v3d_strings_arena == NULL) {
|
|
|
|
|
g_v3d_strings_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 14), __func__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vos = BLI_memarena_alloc(g_v3d_strings_arena, sizeof(ViewCachedString) + alloc_len);
|
|
|
|
|
|
|
|
|
|
BLI_LINKS_PREPEND(g_v3d_strings[g_v3d_string_level], vos);
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2010-10-19 02:41:09 +00:00
|
|
|
copy_v3_v3(vos->vec, co);
|
2015-10-11 01:44:47 +02:00
|
|
|
copy_v4_v4_uchar(vos->col.ub, col);
|
2012-03-25 23:54:33 +00:00
|
|
|
vos->xoffs = xoffs;
|
|
|
|
|
vos->flag = flag;
|
2014-04-17 15:14:07 +10:00
|
|
|
vos->str_len = str_len;
|
2010-10-30 23:02:38 +00:00
|
|
|
|
|
|
|
|
/* allocate past the end */
|
2014-06-15 04:06:44 +10:00
|
|
|
memcpy(vos->str, str, alloc_len);
|
2009-05-18 16:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, float mat[4][4])
|
2009-05-18 16:42:34 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
2009-09-19 18:45:31 +00:00
|
|
|
ViewCachedString *vos;
|
2012-03-25 23:54:33 +00:00
|
|
|
int tot = 0;
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
BLI_assert(g_v3d_string_level >= 0 && g_v3d_string_level <= 2);
|
|
|
|
|
|
2009-05-18 16:42:34 +00:00
|
|
|
/* project first and test */
|
2014-04-17 15:14:07 +10:00
|
|
|
for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (mat && !(vos->flag & V3D_CACHE_TEXT_WORLDSPACE))
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(mat, vos->vec);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
refactor ED_view3d_project_short & ED_view3d_project_short_noclip,
This is apart of a code cleanup to make ED_view3d_project_short/ED_view3d_project_int/ED_view3d_project_float interchangeable. Currently they work very differently in a way thats quite confusing (and cause of bugs in blender that remain uncorrected) - fixes coming.
There are also cases where ED_view3d_project_short is used, then the values are converted from shorts into int's after because ED_view3d_project_int() behaves differently, will unify behavior of these functions after this commit.
- rather then clip/noclip versions, pass flags (for bound-box clip, window clip).
- rather then store the invalid clip-value, return success (or error value clip_near, clip_bb, clip_win, overflow).
- remove local copies of project functions from drawobject.c: view3d_project_short_clip, view3d_project_short_noclip, view3d_project_short_clip_persmat.
add functions:
- ED_view3d_project_short_global() global space projection
- ED_view3d_project_short_object() object space projection.
- ED_view3d_project_short_ex() take perspective matrix and local space option as args.
- ED_view3d_project_base() - special function to set the Object 'Base' screen coords (sx, sy), since this is a common enough operation.
2012-10-04 16:46:15 +00:00
|
|
|
if (ED_view3d_project_short_ex(ar,
|
2012-10-11 03:25:19 +00:00
|
|
|
(vos->flag & V3D_CACHE_TEXT_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob,
|
|
|
|
|
(vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0,
|
|
|
|
|
vos->vec, vos->sco,
|
2012-12-21 03:49:47 +00:00
|
|
|
V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
|
refactor ED_view3d_project_short & ED_view3d_project_short_noclip,
This is apart of a code cleanup to make ED_view3d_project_short/ED_view3d_project_int/ED_view3d_project_float interchangeable. Currently they work very differently in a way thats quite confusing (and cause of bugs in blender that remain uncorrected) - fixes coming.
There are also cases where ED_view3d_project_short is used, then the values are converted from shorts into int's after because ED_view3d_project_int() behaves differently, will unify behavior of these functions after this commit.
- rather then clip/noclip versions, pass flags (for bound-box clip, window clip).
- rather then store the invalid clip-value, return success (or error value clip_near, clip_bb, clip_win, overflow).
- remove local copies of project functions from drawobject.c: view3d_project_short_clip, view3d_project_short_noclip, view3d_project_short_clip_persmat.
add functions:
- ED_view3d_project_short_global() global space projection
- ED_view3d_project_short_object() object space projection.
- ED_view3d_project_short_ex() take perspective matrix and local space option as args.
- ED_view3d_project_base() - special function to set the Object 'Base' screen coords (sx, sy), since this is a common enough operation.
2012-10-04 16:46:15 +00:00
|
|
|
{
|
2009-05-18 16:42:34 +00:00
|
|
|
tot++;
|
refactor ED_view3d_project_short & ED_view3d_project_short_noclip,
This is apart of a code cleanup to make ED_view3d_project_short/ED_view3d_project_int/ED_view3d_project_float interchangeable. Currently they work very differently in a way thats quite confusing (and cause of bugs in blender that remain uncorrected) - fixes coming.
There are also cases where ED_view3d_project_short is used, then the values are converted from shorts into int's after because ED_view3d_project_int() behaves differently, will unify behavior of these functions after this commit.
- rather then clip/noclip versions, pass flags (for bound-box clip, window clip).
- rather then store the invalid clip-value, return success (or error value clip_near, clip_bb, clip_win, overflow).
- remove local copies of project functions from drawobject.c: view3d_project_short_clip, view3d_project_short_noclip, view3d_project_short_clip_persmat.
add functions:
- ED_view3d_project_short_global() global space projection
- ED_view3d_project_short_object() object space projection.
- ED_view3d_project_short_ex() take perspective matrix and local space option as args.
- ED_view3d_project_base() - special function to set the Object 'Base' screen coords (sx, sy), since this is a common enough operation.
2012-10-04 16:46:15 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
vos->sco[0] = IS_CLIPPED;
|
|
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
}
|
2009-09-19 18:45:31 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (tot) {
|
2012-03-25 23:54:33 +00:00
|
|
|
int col_pack_prev = 0;
|
2010-12-20 03:59:22 +00:00
|
|
|
|
2010-04-08 11:46:52 +00:00
|
|
|
#if 0
|
2010-02-19 20:09:42 +00:00
|
|
|
bglMats mats; /* ZBuffer depth vars */
|
|
|
|
|
double ux, uy, uz;
|
|
|
|
|
float depth;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->zbuf)
|
2010-02-19 20:09:42 +00:00
|
|
|
bgl_get_mats(&mats);
|
2010-04-08 11:46:52 +00:00
|
|
|
#endif
|
2012-02-28 13:03:56 +00:00
|
|
|
if (rv3d->rflag & RV3D_CLIPPING) {
|
|
|
|
|
ED_view3d_clipping_disable();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glPushMatrix();
|
2014-09-10 15:01:39 +10:00
|
|
|
wmOrtho2_region_ui(ar);
|
|
|
|
|
glLoadIdentity();
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (depth_write) {
|
|
|
|
|
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
2009-09-19 18:45:31 +00:00
|
|
|
}
|
2012-02-28 13:03:56 +00:00
|
|
|
else {
|
|
|
|
|
glDepthMask(0);
|
|
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (vos->sco[0] != IS_CLIPPED) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (col_pack_prev != vos->col.pack) {
|
2010-12-20 03:59:22 +00:00
|
|
|
glColor3ubv(vos->col.ub);
|
2012-03-25 23:54:33 +00:00
|
|
|
col_pack_prev = vos->col.pack;
|
2010-12-20 03:59:22 +00:00
|
|
|
}
|
2012-02-28 13:03:56 +00:00
|
|
|
|
2011-12-03 20:49:41 +00:00
|
|
|
((vos->flag & V3D_CACHE_TEXT_ASCII) ?
|
2012-03-25 23:54:33 +00:00
|
|
|
BLF_draw_default_ascii :
|
|
|
|
|
BLF_draw_default
|
2014-06-15 04:06:44 +10:00
|
|
|
)((float)(vos->sco[0] + vos->xoffs),
|
|
|
|
|
(float)(vos->sco[1]),
|
2012-03-25 23:54:33 +00:00
|
|
|
(depth_write) ? 0.0f : 2.0f,
|
2014-06-15 04:06:44 +10:00
|
|
|
vos->str,
|
2012-03-25 23:54:33 +00:00
|
|
|
vos->str_len);
|
2009-05-18 16:42:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-04-17 15:14:07 +10:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (depth_write) {
|
|
|
|
|
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
2009-09-19 18:45:31 +00:00
|
|
|
}
|
2012-10-11 03:25:19 +00:00
|
|
|
else {
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
glPopMatrix();
|
2009-05-18 16:42:34 +00:00
|
|
|
|
2012-02-28 13:03:56 +00:00
|
|
|
if (rv3d->rflag & RV3D_CLIPPING) {
|
|
|
|
|
ED_view3d_clipping_enable();
|
|
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
}
|
2014-04-17 15:14:07 +10:00
|
|
|
|
|
|
|
|
g_v3d_strings[g_v3d_string_level] = NULL;
|
|
|
|
|
|
|
|
|
|
if (g_v3d_string_level == 0) {
|
|
|
|
|
if (g_v3d_strings_arena) {
|
|
|
|
|
BLI_memarena_free(g_v3d_strings_arena);
|
|
|
|
|
g_v3d_strings_arena = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_v3d_string_level--;
|
2009-05-18 16:42:34 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-09-19 18:45:31 +00:00
|
|
|
/* ******************** primitive drawing ******************* */
|
|
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* draws a cube given the scaling of the cube, assuming that
|
2008-12-19 12:14:58 +00:00
|
|
|
* all required matrices have been set (used for drawing empties)
|
|
|
|
|
*/
|
|
|
|
|
static void drawcube_size(float size)
|
|
|
|
|
{
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(-size, -size, -size); glVertex3f(-size, -size, size);
|
|
|
|
|
glVertex3f(-size, size, size); glVertex3f(-size, size, -size);
|
2011-12-03 20:49:41 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(-size, -size, -size); glVertex3f(size, -size, -size);
|
|
|
|
|
glVertex3f(size, -size, size); glVertex3f(size, size, size);
|
2011-12-03 20:49:41 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(size, size, -size); glVertex3f(size, -size, -size);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(-size, -size, size); glVertex3f(size, -size, size);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(-size, size, size); glVertex3f(size, size, size);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(-size, size, -size); glVertex3f(size, size, -size);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* this is an unused (old) cube-drawing function based on a given size */
|
|
|
|
|
#if 0
|
2011-09-11 02:50:01 +00:00
|
|
|
static void drawcube_size(const float size[3])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
glPushMatrix();
|
2015-09-20 18:11:25 +02:00
|
|
|
glScale3fv(size);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]);
|
|
|
|
|
glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(cube[7]); glVertex3fv(cube[4]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(cube[1]); glVertex3fv(cube[5]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(cube[2]); glVertex3fv(cube[6]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(cube[3]); glVertex3fv(cube[7]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
static void drawshadbuflimits(Lamp *la, float mat[4][4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
float sta[3], end[3], lavec[3];
|
|
|
|
|
|
2010-06-10 07:57:25 +00:00
|
|
|
negate_v3_v3(lavec, mat[2]);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(lavec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-07-31 10:58:10 +00:00
|
|
|
madd_v3_v3v3fl(sta, mat[3], lavec, la->clipsta);
|
|
|
|
|
madd_v3_v3v3fl(end, mat[3], lavec, la->clipend);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(sta);
|
|
|
|
|
glVertex3fv(end);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glPointSize(3.0);
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
bglVertex3fv(sta);
|
|
|
|
|
bglVertex3fv(end);
|
|
|
|
|
bglEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-11 02:50:01 +00:00
|
|
|
static void spotvolume(float lvec[3], float vvec[3], const float inp)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
/* camera is at 0,0,0 */
|
2012-03-25 23:54:33 +00:00
|
|
|
float temp[3], plane[3], mat1[3][3], mat2[3][3], mat3[3][3], mat4[3][3], q[4], co, si, angle;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(lvec);
|
2012-03-25 23:54:33 +00:00
|
|
|
normalize_v3(vvec); /* is this the correct vector ? */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
cross_v3_v3v3(temp, vvec, lvec); /* equation for a plane through vvec and lvec */
|
|
|
|
|
cross_v3_v3v3(plane, lvec, temp); /* a plane perpendicular to this, parallel with lvec */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-12-08 00:58:15 +00:00
|
|
|
/* vectors are exactly aligned, use the X axis, this is arbitrary */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (normalize_v3(plane) == 0.0f)
|
2012-03-25 23:54:33 +00:00
|
|
|
plane[1] = 1.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* now we've got two equations: one of a cone and one of a plane, but we have
|
2012-03-04 04:35:12 +00:00
|
|
|
* three unknowns. We remove one unknown by rotating the plane to z=0 (the plane normal) */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* rotate around cross product vector of (0,0,1) and plane normal, dot product degrees */
|
|
|
|
|
/* according definition, we derive cross product is (plane[1],-plane[0],0), en cos = plane[2]);*/
|
|
|
|
|
|
|
|
|
|
/* translating this comment to english didnt really help me understanding the math! :-) (ton) */
|
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
q[1] = plane[1];
|
|
|
|
|
q[2] = -plane[0];
|
|
|
|
|
q[3] = 0;
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(&q[1]);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
angle = saacos(plane[2]) / 2.0f;
|
2011-09-11 02:50:01 +00:00
|
|
|
co = cosf(angle);
|
2012-03-25 23:54:33 +00:00
|
|
|
si = sqrtf(1 - co * co);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
q[0] = co;
|
|
|
|
|
q[1] *= si;
|
|
|
|
|
q[2] *= si;
|
|
|
|
|
q[3] = 0;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
quat_to_mat3(mat1, q);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* rotate lamp vector now over acos(inp) degrees */
|
2010-07-31 10:58:10 +00:00
|
|
|
copy_v3_v3(vvec, lvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m3(mat2);
|
2008-12-19 12:14:58 +00:00
|
|
|
co = inp;
|
2012-03-25 23:54:33 +00:00
|
|
|
si = sqrtf(1.0f - inp * inp);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
mat2[0][0] = co;
|
|
|
|
|
mat2[1][0] = -si;
|
|
|
|
|
mat2[0][1] = si;
|
|
|
|
|
mat2[1][1] = co;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_m3m3(mat3, mat2, mat1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
mat2[1][0] = si;
|
|
|
|
|
mat2[0][1] = -si;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_m3m3(mat4, mat2, mat1);
|
2009-11-10 20:43:45 +00:00
|
|
|
transpose_m3(mat1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_m3m3(mat2, mat1, mat3);
|
|
|
|
|
mul_m3_v3(mat2, lvec);
|
|
|
|
|
mul_m3_m3m3(mat2, mat1, mat4);
|
|
|
|
|
mul_m3_v3(mat2, vvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-01-25 14:47:32 +00:00
|
|
|
static void draw_spot_cone(Lamp *la, float x, float z)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-03-01 14:20:54 +11:00
|
|
|
z = fabsf(z);
|
2010-01-25 14:47:32 +00:00
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLE_FAN);
|
|
|
|
|
glVertex3f(0.0f, 0.0f, -x);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (la->mode & LA_SQUARE) {
|
2010-06-10 19:35:37 +00:00
|
|
|
glVertex3f(z, z, 0);
|
|
|
|
|
glVertex3f(-z, z, 0);
|
|
|
|
|
glVertex3f(-z, -z, 0);
|
|
|
|
|
glVertex3f(z, -z, 0);
|
|
|
|
|
glVertex3f(z, z, 0);
|
2010-01-25 14:47:32 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int a = 0; a < 33; a++) {
|
|
|
|
|
float angle = a * M_PI * 2 / (33 - 1);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(z * cosf(angle), z * sinf(angle), 0);
|
2010-01-25 14:47:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void draw_transp_spot_volume(Lamp *la, float x, float z)
|
|
|
|
|
{
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glDepthMask(0);
|
|
|
|
|
|
|
|
|
|
/* draw backside darkening */
|
|
|
|
|
glCullFace(GL_FRONT);
|
|
|
|
|
|
|
|
|
|
glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
|
|
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
|
|
|
|
|
|
|
|
|
draw_spot_cone(la, x, z);
|
|
|
|
|
|
2010-07-20 10:41:08 +00:00
|
|
|
/* draw front side lighting */
|
2010-01-25 14:47:32 +00:00
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glBlendFunc(GL_ONE, GL_ONE);
|
2010-01-25 14:47:32 +00:00
|
|
|
glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
|
|
|
|
|
|
|
|
|
|
draw_spot_cone(la, x, z);
|
|
|
|
|
|
|
|
|
|
/* restore state */
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
#ifdef WITH_GAMEENGINE
|
|
|
|
|
static void draw_transp_sun_volume(Lamp *la)
|
|
|
|
|
{
|
|
|
|
|
float box[8][3];
|
|
|
|
|
|
|
|
|
|
/* construct box */
|
|
|
|
|
box[0][0] = box[1][0] = box[2][0] = box[3][0] = -la->shadow_frustum_size;
|
|
|
|
|
box[4][0] = box[5][0] = box[6][0] = box[7][0] = +la->shadow_frustum_size;
|
|
|
|
|
box[0][1] = box[1][1] = box[4][1] = box[5][1] = -la->shadow_frustum_size;
|
|
|
|
|
box[2][1] = box[3][1] = box[6][1] = box[7][1] = +la->shadow_frustum_size;
|
|
|
|
|
box[0][2] = box[3][2] = box[4][2] = box[7][2] = -la->clipend;
|
|
|
|
|
box[1][2] = box[2][2] = box[5][2] = box[6][2] = -la->clipsta;
|
|
|
|
|
|
|
|
|
|
/* draw edges */
|
|
|
|
|
draw_box(box, false);
|
|
|
|
|
|
|
|
|
|
/* draw faces */
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glDepthMask(0);
|
|
|
|
|
|
|
|
|
|
/* draw backside darkening */
|
|
|
|
|
glCullFace(GL_FRONT);
|
|
|
|
|
|
|
|
|
|
glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
|
|
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
|
|
|
|
|
|
|
|
|
draw_box(box, true);
|
|
|
|
|
|
|
|
|
|
/* draw front side lighting */
|
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
|
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE);
|
|
|
|
|
glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
|
|
|
|
|
|
|
|
|
|
draw_box(box, true);
|
|
|
|
|
|
|
|
|
|
/* restore state */
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-04-11 15:41:20 +10:00
|
|
|
static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
|
|
|
|
|
const char dt, const short dflag, const unsigned char ob_wire_col[4], const bool is_obact)
|
2010-01-25 14:47:32 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
|
|
|
|
const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]);
|
|
|
|
|
Lamp *la = ob->data;
|
2015-10-15 22:36:31 +11:00
|
|
|
float vec[3], lvec[3], vvec[3], circrad;
|
2010-11-05 05:26:34 +00:00
|
|
|
float lampsize;
|
2012-06-06 18:00:08 +00:00
|
|
|
float imat[4][4];
|
|
|
|
|
|
|
|
|
|
unsigned char curcol[4];
|
2010-12-20 03:59:22 +00:00
|
|
|
unsigned char col[4];
|
2015-03-30 00:51:00 -04:00
|
|
|
/* cone can't be drawn for duplicated lamps, because duplilist would be freed */
|
2010-12-07 20:22:35 +00:00
|
|
|
/* the moment of view3d_draw_transp() call */
|
2013-03-24 12:13:13 +00:00
|
|
|
const bool is_view = (rv3d->persp == RV3D_CAMOB && v3d->camera == base->object);
|
|
|
|
|
const bool drawcone = ((dt > OB_WIRE) &&
|
|
|
|
|
!(G.f & G_PICKSEL) &&
|
|
|
|
|
(la->type == LA_SPOT) &&
|
|
|
|
|
(la->mode & LA_SHOW_CONE) &&
|
|
|
|
|
!(base->flag & OB_FROMDUPLI) &&
|
|
|
|
|
!is_view);
|
2010-12-07 20:22:35 +00:00
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
#ifdef WITH_GAMEENGINE
|
|
|
|
|
const bool drawshadowbox = (
|
|
|
|
|
(rv3d->rflag & RV3D_IS_GAME_ENGINE) &&
|
|
|
|
|
(dt > OB_WIRE) &&
|
|
|
|
|
!(G.f & G_PICKSEL) &&
|
|
|
|
|
(la->type == LA_SUN) &&
|
|
|
|
|
((la->mode & LA_SHAD_BUF) ||
|
|
|
|
|
(la->mode & LA_SHAD_RAY)) &&
|
|
|
|
|
(la->mode & LA_SHOW_SHADOW_BOX) &&
|
|
|
|
|
!(base->flag & OB_FROMDUPLI) &&
|
|
|
|
|
!is_view);
|
|
|
|
|
#else
|
|
|
|
|
const bool drawshadowbox = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if ((drawcone || drawshadowbox) && !v3d->transp) {
|
2010-01-25 14:47:32 +00:00
|
|
|
/* in this case we need to draw delayed */
|
2012-06-10 10:15:49 +00:00
|
|
|
ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
|
2010-01-25 14:47:32 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* we first draw only the screen aligned & fixed scale stuff */
|
|
|
|
|
glPushMatrix();
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* lets calculate the scale: */
|
2012-03-25 23:54:33 +00:00
|
|
|
lampsize = pixsize * ((float)U.obcenter_dia * 0.5f);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* and view aligned matrix: */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(imat, rv3d->viewinv);
|
|
|
|
|
normalize_v3(imat[0]);
|
|
|
|
|
normalize_v3(imat[1]);
|
2010-10-07 10:04:07 +00:00
|
|
|
|
|
|
|
|
/* lamp center */
|
|
|
|
|
copy_v3_v3(vec, ob->obmat[3]);
|
2012-06-07 08:02:48 +00:00
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2012-06-07 08:02:48 +00:00
|
|
|
/* for AA effects */
|
|
|
|
|
curcol[0] = ob_wire_col[0];
|
|
|
|
|
curcol[1] = ob_wire_col[1];
|
|
|
|
|
curcol[2] = ob_wire_col[2];
|
|
|
|
|
curcol[3] = 154;
|
|
|
|
|
glColor4ubv(curcol);
|
|
|
|
|
}
|
2012-06-06 18:00:08 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (lampsize > 0.0f) {
|
2010-01-03 01:55:20 +00:00
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2012-06-07 08:02:48 +00:00
|
|
|
if (ob->id.us > 1) {
|
2014-04-11 15:41:20 +10:00
|
|
|
if (is_obact || (ob->flag & SELECT)) {
|
|
|
|
|
glColor4ub(0x88, 0xFF, 0xFF, 155);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glColor4ub(0x77, 0xCC, 0xCC, 155);
|
|
|
|
|
}
|
2012-06-07 08:02:48 +00:00
|
|
|
}
|
2010-01-03 01:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Inner Circle */
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
drawcircball(GL_LINE_LOOP, vec, lampsize, imat);
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
drawcircball(GL_POLYGON, vec, lampsize, imat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-01-03 01:55:20 +00:00
|
|
|
/* restore */
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2012-06-07 08:02:48 +00:00
|
|
|
if (ob->id.us > 1)
|
|
|
|
|
glColor4ubv(curcol);
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2010-01-03 01:55:20 +00:00
|
|
|
/* Outer circle */
|
2012-03-25 23:54:33 +00:00
|
|
|
circrad = 3.0f * lampsize;
|
2010-05-22 11:58:21 +00:00
|
|
|
setlinestyle(3);
|
|
|
|
|
|
2010-01-03 01:55:20 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, circrad, imat);
|
2010-05-22 11:58:21 +00:00
|
|
|
|
|
|
|
|
/* draw dashed outer circle if shadow is on. remember some lamps can't have certain shadows! */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (la->type != LA_HEMI) {
|
2012-03-18 06:01:33 +00:00
|
|
|
if ((la->mode & LA_SHAD_RAY) || ((la->mode & LA_SHAD_BUF) && (la->type == LA_SPOT))) {
|
2012-03-25 23:54:33 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, circrad + 3.0f * pixsize, imat);
|
2010-05-22 11:58:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-01-03 01:55:20 +00:00
|
|
|
}
|
2010-05-22 11:58:21 +00:00
|
|
|
else {
|
|
|
|
|
setlinestyle(3);
|
2010-01-08 17:53:17 +00:00
|
|
|
circrad = 0.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw the pretty sun rays */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (la->type == LA_SUN) {
|
2008-12-19 12:14:58 +00:00
|
|
|
float v1[3], v2[3], mat[3][3];
|
|
|
|
|
short axis;
|
|
|
|
|
|
|
|
|
|
/* setup a 45 degree rotation matrix */
|
2014-04-30 02:12:11 +10:00
|
|
|
axis_angle_normalized_to_mat3_ex(mat, imat[2], M_SQRT1_2, M_SQRT1_2);
|
2013-06-22 23:58:52 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* vectors */
|
2010-07-31 10:58:10 +00:00
|
|
|
mul_v3_v3fl(v1, imat[0], circrad * 1.2f);
|
|
|
|
|
mul_v3_v3fl(v2, imat[0], circrad * 2.5f);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* center */
|
2015-09-20 18:11:25 +02:00
|
|
|
glTranslate3fv(vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
for (axis = 0; axis < 8; axis++) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(mat, v1);
|
|
|
|
|
mul_m3_v3(mat, v2);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glTranslatef(-vec[0], -vec[1], -vec[2]);
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (la->type == LA_LOCAL) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (la->mode & LA_SPHERE) {
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, la->dist, imat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glPopMatrix(); /* back in object space */
|
2010-07-31 10:58:10 +00:00
|
|
|
zero_v3(vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (is_view) {
|
2011-01-03 06:45:47 +00:00
|
|
|
/* skip drawing extra info */
|
|
|
|
|
}
|
2015-10-23 04:54:07 +11:00
|
|
|
else if (la->type == LA_SPOT) {
|
2015-10-15 22:36:31 +11:00
|
|
|
float x, y, z, z_abs;
|
2013-11-24 21:25:05 +11:00
|
|
|
copy_v3_fl3(lvec, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
copy_v3_fl3(vvec, rv3d->persmat[0][2], rv3d->persmat[1][2], rv3d->persmat[2][2]);
|
2014-04-30 04:52:31 +10:00
|
|
|
mul_transposed_mat3_m4_v3(ob->obmat, vvec);
|
2013-11-24 21:25:05 +11:00
|
|
|
|
|
|
|
|
x = -la->dist;
|
Cleanup: Internal degrees removal.
This patch changes most of the reamining degrees usage in internal code into radians.
I let a few which I know off asside, for reasons explained below - and I'm not sure to have found out all of them.
WARNING: this introduces forward incompatibility, which means files saved from this version won't open 100% correctly
in previous versions (a few angle properties would use radians values as degrees...).
Details:
- Data:
-- Lamp.spotsize: Game engine exposed this setting in degrees, to not break the API here I kept it as such
(using getter/setter functions), still using radians internally.
-- Mesh.smoothresh: Didn't touch to this one, as we will hopefully replace it completely by loop normals currently in dev.
- Modifiers:
-- EdgeSplitModifierData.split_angle, BevelModifierData.bevel_angle: Done.
- Postprocessing:
-- WipeVars.angle (sequencer's effect), NodeBokehImage.angle, NodeBoxMask.rotation, NodeEllipseMask.rotation: Done.
- BGE:
-- bConstraintActuator: Orientation type done (the minloc[0] & maxloc[0] cases). Did not touch to 'limit location' type,
it can also limit rotation, but it exposes through RNA the same limit_min/limit_max, which hence
can be either distance or angle values, depending on the mode. Will leave this to BGE team.
-- bSoundActuator.cone_outer_angle_3d, bSoundActuator.cone_inner_angle_3d: Done (note I kept degrees in BGE itself,
as it seems this is the expected value here...).
-- bRadarSensor.angle: Done.
Reviewers: brecht, campbellbarton, sergey, gaiaclary, dfelinto, moguri, jbakker, lukastoenne, howardt
Reviewed By: brecht, campbellbarton, sergey, gaiaclary, moguri, jbakker, lukastoenne, howardt
Thanks to all!
Differential Revision: http://developer.blender.org/D59
2013-12-03 20:09:25 +01:00
|
|
|
y = cosf(la->spotsize * 0.5f);
|
2013-11-24 21:25:05 +11:00
|
|
|
z = x * sqrtf(1.0f - y * y);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
spotvolume(lvec, vvec, y);
|
2010-01-25 14:47:32 +00:00
|
|
|
mul_v3_fl(lvec, x);
|
|
|
|
|
mul_v3_fl(vvec, x);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
x *= y;
|
|
|
|
|
|
2015-10-15 22:36:31 +11:00
|
|
|
z_abs = fabsf(z);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (la->mode & LA_SQUARE) {
|
2015-10-15 22:36:31 +11:00
|
|
|
/* draw pyramid */
|
|
|
|
|
const float vertices[5][3] = {
|
|
|
|
|
/* 5 of vertex coords of pyramid */
|
|
|
|
|
{0.0f, 0.0f, 0.0f},
|
|
|
|
|
{z_abs, z_abs, x},
|
|
|
|
|
{-z_abs, -z_abs, x},
|
|
|
|
|
{z_abs, -z_abs, x},
|
|
|
|
|
{-z_abs, z_abs, x},
|
|
|
|
|
};
|
|
|
|
|
const unsigned char indices[] = {
|
|
|
|
|
0, 1, 3,
|
|
|
|
|
0, 3, 2,
|
|
|
|
|
0, 2, 4,
|
|
|
|
|
0, 1, 4,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Draw call:
|
|
|
|
|
* activate and specify pointer to vertex array */
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, vertices);
|
|
|
|
|
/* draw the pyramid */
|
|
|
|
|
glDrawElements(GL_LINE_STRIP, 12, GL_UNSIGNED_BYTE, indices);
|
|
|
|
|
|
|
|
|
|
/* deactivate vertex arrays after drawing */
|
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
|
|
|
|
|
glTranslatef(0.0f, 0.0f, x);
|
|
|
|
|
|
|
|
|
|
/* draw the square representing spotbl */
|
|
|
|
|
if (la->type == LA_SPOT) {
|
|
|
|
|
float blend = z_abs * (1.0f - pow2f(la->spotblend));
|
|
|
|
|
|
|
|
|
|
/* hide line if it is zero size or overlaps with outer border,
|
|
|
|
|
* previously it adjusted to always to show it but that seems
|
|
|
|
|
* confusing because it doesn't show the actual blend size */
|
|
|
|
|
if (blend != 0.0f && blend != z_abs) {
|
|
|
|
|
fdrawbox(blend, -blend, -blend, blend);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-10-11 03:25:19 +00:00
|
|
|
else {
|
|
|
|
|
|
2015-10-15 22:36:31 +11:00
|
|
|
/* draw the angled sides of the cone */
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(vvec);
|
|
|
|
|
glVertex3fv(vec);
|
|
|
|
|
glVertex3fv(lvec);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
/* draw the circle at the end of the cone */
|
|
|
|
|
glTranslatef(0.0f, 0.0f, x);
|
|
|
|
|
circ(0.0f, 0.0f, z_abs);
|
|
|
|
|
|
|
|
|
|
/* draw the circle representing spotbl */
|
|
|
|
|
if (la->type == LA_SPOT) {
|
|
|
|
|
float blend = z_abs * (1.0f - pow2f(la->spotblend));
|
|
|
|
|
|
|
|
|
|
/* hide line if it is zero size or overlaps with outer border,
|
|
|
|
|
* previously it adjusted to always to show it but that seems
|
|
|
|
|
* confusing because it doesn't show the actual blend size */
|
|
|
|
|
if (blend != 0.0f && blend != z_abs) {
|
|
|
|
|
circ(0.0f, 0.0f, blend);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2010-01-25 14:47:32 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (drawcone)
|
2010-01-25 14:47:32 +00:00
|
|
|
draw_transp_spot_volume(la, x, z);
|
2010-06-10 07:57:25 +00:00
|
|
|
|
|
|
|
|
/* draw clip start, useful for wide cones where its not obvious where the start is */
|
2012-03-25 23:54:33 +00:00
|
|
|
glTranslatef(0.0, 0.0, -x); /* reverse translation above */
|
2014-01-16 19:15:53 +11:00
|
|
|
if (la->type == LA_SPOT && (la->mode & LA_SHAD_BUF)) {
|
2010-06-10 07:57:25 +00:00
|
|
|
float lvec_clip[3];
|
|
|
|
|
float vvec_clip[3];
|
2012-03-25 23:54:33 +00:00
|
|
|
float clipsta_fac = la->clipsta / -x;
|
2010-06-10 07:57:25 +00:00
|
|
|
|
|
|
|
|
interp_v3_v3v3(lvec_clip, vec, lvec, clipsta_fac);
|
|
|
|
|
interp_v3_v3v3(vvec_clip, vec, vvec, clipsta_fac);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(lvec_clip);
|
|
|
|
|
glVertex3fv(vvec_clip);
|
2010-06-10 07:57:25 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
2012-12-21 20:25:02 +00:00
|
|
|
/* Else, draw spot direction (using distance as end limit, same as for Area lamp). */
|
|
|
|
|
else {
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3f(0.0, 0.0, -circrad);
|
|
|
|
|
glVertex3f(0.0, 0.0, -la->dist);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 22:35:18 +00:00
|
|
|
else if (ELEM(la->type, LA_HEMI, LA_SUN)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw the line from the circle along the dist */
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
vec[2] = -circrad;
|
|
|
|
|
glVertex3fv(vec);
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = -la->dist;
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (la->type == LA_HEMI) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw the hemisphere curves */
|
|
|
|
|
short axis, steps, dir;
|
|
|
|
|
float outdist, zdist, mul;
|
2010-07-31 10:58:10 +00:00
|
|
|
zero_v3(vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
outdist = 0.14; mul = 1.4; dir = 1;
|
|
|
|
|
|
|
|
|
|
setlinestyle(4);
|
|
|
|
|
/* loop over the 4 compass points, and draw each arc as a LINE_STRIP */
|
2012-03-25 23:54:33 +00:00
|
|
|
for (axis = 0; axis < 4; axis++) {
|
|
|
|
|
float v[3] = {0.0, 0.0, 0.0};
|
2008-12-19 12:14:58 +00:00
|
|
|
zdist = 0.02;
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (steps = 0; steps < 6; steps++) {
|
|
|
|
|
if (axis == 0 || axis == 1) { /* x axis up, x axis down */
|
2008-12-19 12:14:58 +00:00
|
|
|
/* make the arcs start at the edge of the energy circle */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (steps == 0) v[0] = dir * circrad;
|
|
|
|
|
else v[0] = v[0] + dir * (steps * outdist);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (axis == 2 || axis == 3) { /* y axis up, y axis down */
|
2008-12-19 12:14:58 +00:00
|
|
|
/* make the arcs start at the edge of the energy circle */
|
2012-03-18 06:01:33 +00:00
|
|
|
v[1] = (steps == 0) ? (dir * circrad) : (v[1] + dir * (steps * outdist));
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
v[2] = v[2] - steps * zdist;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glVertex3fv(v);
|
|
|
|
|
|
|
|
|
|
zdist = zdist * mul;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
/* flip the direction */
|
|
|
|
|
dir = -dir;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-18 12:28:19 +02:00
|
|
|
|
|
|
|
|
#ifdef WITH_GAMEENGINE
|
|
|
|
|
if (drawshadowbox) {
|
|
|
|
|
draw_transp_sun_volume(la);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (la->type == LA_AREA) {
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(3);
|
2012-03-25 23:54:33 +00:00
|
|
|
if (la->area_shape == LA_AREA_SQUARE)
|
|
|
|
|
fdrawbox(-la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
|
|
|
|
|
else if (la->area_shape == LA_AREA_RECT)
|
|
|
|
|
fdrawbox(-la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(0.0, 0.0, -circrad);
|
|
|
|
|
glVertex3f(0.0, 0.0, -la->dist);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* and back to viewspace */
|
2013-11-05 15:53:55 +00:00
|
|
|
glPushMatrix();
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2010-08-01 11:00:36 +00:00
|
|
|
copy_v3_v3(vec, ob->obmat[3]);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if ((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == false)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
drawshadbuflimits(la, ob->obmat);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
UI_GetThemeColor4ubv(TH_LAMP, col);
|
|
|
|
|
glColor4ubv(col);
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (vec[2] > 0) vec[2] -= circrad;
|
2008-12-19 12:14:58 +00:00
|
|
|
else vec[2] += circrad;
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(vec);
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 0;
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glPointSize(2.0);
|
|
|
|
|
glBegin(GL_POINTS);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2012-06-07 08:02:48 +00:00
|
|
|
/* restore for drawing extra stuff */
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2013-11-05 15:53:55 +00:00
|
|
|
/* and finally back to org object space! */
|
|
|
|
|
glPopMatrix();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-05 19:30:59 +01:00
|
|
|
static void draw_limit_line(float sta, float end, const short dflag, const unsigned char col[3])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3f(0.0, 0.0, -sta);
|
|
|
|
|
glVertex3f(0.0, 0.0, -end);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (!(dflag & DRAW_PICKING)) {
|
|
|
|
|
glPointSize(3.0);
|
|
|
|
|
glBegin(GL_POINTS);
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2015-11-05 19:30:59 +01:00
|
|
|
glColor3ubv(col);
|
2014-06-04 14:22:29 +10:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
glVertex3f(0.0, 0.0, -sta);
|
|
|
|
|
glVertex3f(0.0, 0.0, -end);
|
|
|
|
|
glEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
2012-10-11 03:25:19 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* yafray: draw camera focus point (cross, similar to aqsis code in tuhopuu) */
|
2012-03-01 12:20:18 +00:00
|
|
|
/* qdn: now also enabled for Blender to set focus point for defocus composite node */
|
2008-12-19 12:14:58 +00:00
|
|
|
static void draw_focus_cross(float dist, float size)
|
|
|
|
|
{
|
|
|
|
|
glBegin(GL_LINES);
|
2015-03-30 00:51:00 -04:00
|
|
|
glVertex3f(-size, 0.0f, -dist);
|
|
|
|
|
glVertex3f(size, 0.0f, -dist);
|
|
|
|
|
glVertex3f(0.0f, -size, -dist);
|
|
|
|
|
glVertex3f(0.0f, size, -dist);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-21 01:30:26 +00:00
|
|
|
#ifdef VIEW3D_CAMERA_BORDER_HACK
|
2012-06-06 18:00:08 +00:00
|
|
|
unsigned char view3d_camera_border_hack_col[3];
|
2013-03-24 12:13:13 +00:00
|
|
|
bool view3d_camera_border_hack_test = false;
|
2011-07-21 01:30:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* ****************** draw clip data *************** */
|
|
|
|
|
|
|
|
|
|
static void draw_bundle_sphere(void)
|
|
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
static GLuint displist = 0;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
if (displist == 0) {
|
|
|
|
|
GLUquadricObj *qobj;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
displist = glGenLists(1);
|
2011-11-07 12:55:18 +00:00
|
|
|
glNewList(displist, GL_COMPILE);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
qobj = gluNewQuadric();
|
2011-11-07 12:55:18 +00:00
|
|
|
gluQuadricDrawStyle(qobj, GLU_FILL);
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
gluSphere(qobj, 0.05, 8, 8);
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
gluDeleteQuadric(qobj);
|
|
|
|
|
|
|
|
|
|
glEndList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glCallList(displist);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d,
|
2012-06-10 10:15:49 +00:00
|
|
|
MovieClip *clip, MovieTrackingObject *tracking_object,
|
2012-08-17 12:32:13 +00:00
|
|
|
const short dflag, const unsigned char ob_wire_col[4],
|
2013-03-24 12:13:13 +00:00
|
|
|
int *global_track_index, bool draw_selected)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2011-11-07 12:55:18 +00:00
|
|
|
MovieTrackingTrack *track;
|
2011-12-05 18:57:17 +00:00
|
|
|
float mat[4][4], imat[4][4];
|
2012-08-17 12:32:13 +00:00
|
|
|
unsigned char col_unsel[4], col_sel[4];
|
2012-03-25 23:54:33 +00:00
|
|
|
int tracknr = *global_track_index;
|
2012-06-15 11:03:23 +00:00
|
|
|
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
|
2013-05-09 16:38:47 +00:00
|
|
|
float camera_size[3];
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-08-17 12:32:13 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_TEXT, col_unsel);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_SELECT, col_sel);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_get_camera_object_matrix(scene, base->object, mat);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2013-05-09 16:38:47 +00:00
|
|
|
/* we're compensating camera size for bundles size,
|
2015-03-30 00:51:00 -04:00
|
|
|
* to make it so bundles are always displayed with the same size */
|
2013-05-09 16:38:47 +00:00
|
|
|
copy_v3_v3(camera_size, base->object->size);
|
|
|
|
|
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0)
|
|
|
|
|
mul_v3_fl(camera_size, tracking_object->scale);
|
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
glPushMatrix();
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
|
2011-12-05 18:57:17 +00:00
|
|
|
/* current ogl matrix is translated in camera space, bundles should
|
2012-03-03 16:31:46 +00:00
|
|
|
* be rendered in world space, so camera matrix should be "removed"
|
|
|
|
|
* from current ogl matrix */
|
2011-12-05 18:57:17 +00:00
|
|
|
invert_m4_m4(imat, base->object->obmat);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
glMultMatrixf(imat);
|
|
|
|
|
glMultMatrixf(mat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float obmat[4][4];
|
2014-02-26 19:40:04 +06:00
|
|
|
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2014-02-26 19:40:04 +06:00
|
|
|
BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, obmat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
|
|
|
|
invert_m4_m4(imat, obmat);
|
|
|
|
|
glMultMatrixf(imat);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (track = tracksbase->first; track; track = track->next) {
|
2014-04-01 11:34:00 +11:00
|
|
|
bool selected = TRACK_SELECTED(track);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-08 05:36:05 +00:00
|
|
|
if (draw_selected && !selected)
|
2012-02-26 08:14:14 +00:00
|
|
|
continue;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((track->flag & TRACK_HAS_BUNDLE) == 0)
|
2011-11-07 12:55:18 +00:00
|
|
|
continue;
|
|
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if (dflag & DRAW_PICKING)
|
2014-07-23 15:24:07 +02:00
|
|
|
GPU_select_load_id(base->selcol + (tracknr << 16));
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
glPushMatrix();
|
2015-09-20 18:11:25 +02:00
|
|
|
glTranslate3fv(track->bundle_pos);
|
2013-05-09 16:38:47 +00:00
|
|
|
glScalef(v3d->bundle_size / 0.05f / camera_size[0],
|
|
|
|
|
v3d->bundle_size / 0.05f / camera_size[1],
|
|
|
|
|
v3d->bundle_size / 0.05f / camera_size[2]);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (v3d->drawtype == OB_WIRE) {
|
2012-08-17 12:32:13 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glColor3fv(track->color);
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
drawaxes(0.05f, v3d->bundle_drawtype);
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (v3d->drawtype > OB_WIRE) {
|
|
|
|
|
if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) {
|
2012-03-18 06:01:33 +00:00
|
|
|
/* selection outline */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (selected) {
|
2012-08-17 12:32:13 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2015-04-13 16:56:43 -04:00
|
|
|
glLineWidth(2.0f);
|
2012-03-18 06:01:33 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
draw_bundle_sphere();
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
2015-04-13 16:56:43 -04:00
|
|
|
glLineWidth(1.0f);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-08-17 12:32:13 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color);
|
|
|
|
|
else UI_ThemeColor(TH_BUNDLE_SOLID);
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
draw_bundle_sphere();
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-08-17 12:32:13 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (selected) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color);
|
|
|
|
|
else UI_ThemeColor(TH_WIRE);
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
drawaxes(0.05f, v3d->bundle_drawtype);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) {
|
2011-11-07 12:55:18 +00:00
|
|
|
float pos[3];
|
|
|
|
|
|
|
|
|
|
mul_v3_m4v3(pos, mat, track->bundle_pos);
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(pos,
|
|
|
|
|
track->name, strlen(track->name),
|
|
|
|
|
10, V3D_CACHE_TEXT_GLOBALSPACE,
|
|
|
|
|
selected ? col_sel : col_unsel);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-15 16:10:49 +00:00
|
|
|
tracknr++;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_PICKING) == 0) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA)) {
|
2011-12-05 18:57:17 +00:00
|
|
|
MovieTrackingReconstruction *reconstruction;
|
2012-06-15 11:03:23 +00:00
|
|
|
reconstruction = BKE_tracking_object_get_reconstruction(tracking, tracking_object);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (reconstruction->camnr) {
|
2012-03-25 23:54:33 +00:00
|
|
|
MovieReconstructedCamera *camera = reconstruction->cameras;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
UI_ThemeColor(TH_CAMERA_PATH);
|
|
|
|
|
glLineWidth(2.0f);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int a = 0; a < reconstruction->camnr; a++, camera++) {
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(camera->mat[3]);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glLineWidth(1.0f);
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
*global_track_index = tracknr;
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-26 08:14:14 +00:00
|
|
|
static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip,
|
2012-06-10 10:15:49 +00:00
|
|
|
const short dflag, const unsigned char ob_wire_col[4],
|
2013-03-24 12:13:13 +00:00
|
|
|
const bool draw_selected)
|
2011-12-05 18:57:17 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2011-12-05 18:57:17 +00:00
|
|
|
MovieTrackingObject *tracking_object;
|
2012-03-25 23:54:33 +00:00
|
|
|
int global_track_index = 1;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0)
|
2011-12-05 18:57:17 +00:00
|
|
|
return;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (v3d->flag2 & V3D_RENDER_OVERRIDE)
|
2011-12-05 18:57:17 +00:00
|
|
|
return;
|
|
|
|
|
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_colors(NULL, NULL, 0, 1.0f);
|
|
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
|
2015-11-27 21:32:14 +01:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
tracking_object = tracking->objects.first;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (tracking_object) {
|
2011-12-15 16:10:49 +00:00
|
|
|
draw_viewport_object_reconstruction(scene, base, v3d, clip, tracking_object,
|
2012-08-17 12:32:13 +00:00
|
|
|
dflag, ob_wire_col, &global_track_index, draw_selected);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
tracking_object = tracking_object->next;
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
/* restore */
|
|
|
|
|
glShadeModel(GL_FLAT);
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2012-06-07 14:21:25 +00:00
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
if (dflag & DRAW_PICKING)
|
2014-07-23 15:24:07 +02:00
|
|
|
GPU_select_load_id(base->selcol);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void drawcamera_volume(float near_plane[4][3], float far_plane[4][3], const GLenum mode)
|
|
|
|
|
{
|
|
|
|
|
glBegin(mode);
|
|
|
|
|
glVertex3fv(near_plane[0]);
|
|
|
|
|
glVertex3fv(far_plane[0]);
|
|
|
|
|
glVertex3fv(far_plane[1]);
|
|
|
|
|
glVertex3fv(near_plane[1]);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(mode);
|
|
|
|
|
glVertex3fv(near_plane[1]);
|
|
|
|
|
glVertex3fv(far_plane[1]);
|
|
|
|
|
glVertex3fv(far_plane[2]);
|
|
|
|
|
glVertex3fv(near_plane[2]);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(mode);
|
|
|
|
|
glVertex3fv(near_plane[2]);
|
|
|
|
|
glVertex3fv(near_plane[1]);
|
|
|
|
|
glVertex3fv(far_plane[1]);
|
|
|
|
|
glVertex3fv(far_plane[2]);
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glBegin(mode);
|
|
|
|
|
glVertex3fv(far_plane[0]);
|
|
|
|
|
glVertex3fv(near_plane[0]);
|
|
|
|
|
glVertex3fv(near_plane[3]);
|
|
|
|
|
glVertex3fv(far_plane[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* camera frame */
|
|
|
|
|
static void drawcamera_frame(float vec[4][3], const GLenum mode)
|
|
|
|
|
{
|
|
|
|
|
glBegin(mode);
|
|
|
|
|
glVertex3fv(vec[0]);
|
|
|
|
|
glVertex3fv(vec[1]);
|
|
|
|
|
glVertex3fv(vec[2]);
|
|
|
|
|
glVertex3fv(vec[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* center point to camera frame */
|
|
|
|
|
static void drawcamera_framelines(float vec[4][3], float origin[3])
|
|
|
|
|
{
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(vec[1]);
|
|
|
|
|
glVertex3fv(origin);
|
|
|
|
|
glVertex3fv(vec[0]);
|
|
|
|
|
glVertex3fv(vec[3]);
|
|
|
|
|
glVertex3fv(origin);
|
|
|
|
|
glVertex3fv(vec[2]);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool drawcamera_is_stereo3d(Scene *scene, View3D *v3d, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
return (ob == v3d->camera) &&
|
|
|
|
|
(scene->r.scemode & R_MULTIVIEW) != 0 &&
|
|
|
|
|
(v3d->stereo3d_flag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawcamera_stereo3d(
|
|
|
|
|
Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const Camera *cam,
|
|
|
|
|
float vec[4][3], float drawsize, const float scale[3])
|
|
|
|
|
{
|
|
|
|
|
float obmat[4][4];
|
|
|
|
|
float vec_lr[2][4][3];
|
|
|
|
|
const float fac = (cam->stereo.pivot == CAM_S3D_PIVOT_CENTER) ? 2.0f : 1.0f;
|
|
|
|
|
float origin[2][3] = {{0}};
|
|
|
|
|
float tvec[3];
|
|
|
|
|
const Camera *cam_lr[2];
|
|
|
|
|
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
|
|
|
|
|
|
|
|
|
const bool is_stereo3d_cameras = (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS) && (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
|
|
|
|
|
const bool is_stereo3d_plane = (v3d->stereo3d_flag & V3D_S3D_DISPPLANE) && (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
|
|
|
|
|
const bool is_stereo3d_volume = (v3d->stereo3d_flag & V3D_S3D_DISPVOLUME);
|
|
|
|
|
|
|
|
|
|
zero_v3(tvec);
|
|
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
ob = BKE_camera_multiview_render(scene, ob, names[i]);
|
|
|
|
|
cam_lr[i] = ob->data;
|
|
|
|
|
|
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
BKE_camera_multiview_model_matrix(&scene->r, ob, names[i], obmat);
|
|
|
|
|
glMultMatrixf(obmat);
|
|
|
|
|
|
|
|
|
|
copy_m3_m3(vec_lr[i], vec);
|
|
|
|
|
copy_v3_v3(vec_lr[i][3], vec[3]);
|
|
|
|
|
|
|
|
|
|
if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) {
|
|
|
|
|
const float shift_x =
|
|
|
|
|
((BKE_camera_multiview_shift_x(&scene->r, ob, names[i]) - cam->shiftx) *
|
|
|
|
|
(drawsize * scale[0] * fac));
|
|
|
|
|
|
2015-11-23 15:44:15 +11:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
vec_lr[i][j][0] += shift_x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_stereo3d_cameras) {
|
|
|
|
|
/* camera frame */
|
|
|
|
|
drawcamera_frame(vec_lr[i], GL_LINE_LOOP);
|
|
|
|
|
|
|
|
|
|
/* center point to camera frame */
|
|
|
|
|
drawcamera_framelines(vec_lr[i], tvec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* connecting line */
|
|
|
|
|
mul_m4_v3(obmat, origin[i]);
|
|
|
|
|
|
|
|
|
|
/* convergence plane */
|
|
|
|
|
if (is_stereo3d_plane || is_stereo3d_volume) {
|
2015-11-23 15:44:15 +11:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
mul_m4_v3(obmat, vec_lr[i][j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* the remaining drawing takes place in the view space */
|
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
|
|
|
|
|
if (is_stereo3d_cameras) {
|
|
|
|
|
/* draw connecting lines */
|
|
|
|
|
glPushAttrib(GL_ENABLE_BIT);
|
|
|
|
|
|
|
|
|
|
glLineStipple(2, 0xAAAA);
|
|
|
|
|
glEnable(GL_LINE_STIPPLE);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(origin[0]);
|
|
|
|
|
glVertex3fv(origin[1]);
|
|
|
|
|
glEnd();
|
|
|
|
|
glPopAttrib();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw convergence plane*/
|
|
|
|
|
if (is_stereo3d_plane) {
|
|
|
|
|
float axis_center[3], screen_center[3];
|
|
|
|
|
float world_plane[4][3];
|
|
|
|
|
float local_plane[4][3];
|
|
|
|
|
float offset;
|
|
|
|
|
|
|
|
|
|
mid_v3_v3v3(axis_center, origin[0], origin[1]);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
mid_v3_v3v3(world_plane[i], vec_lr[0][i], vec_lr[1][i]);
|
|
|
|
|
sub_v3_v3v3(local_plane[i], world_plane[i], axis_center);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mid_v3_v3v3(screen_center, world_plane[0], world_plane[2]);
|
|
|
|
|
offset = cam->stereo.convergence_distance / len_v3v3(screen_center, axis_center);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
mul_v3_fl(local_plane[i], offset);
|
|
|
|
|
add_v3_v3(local_plane[i], axis_center);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glColor3f(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
/* camera frame */
|
|
|
|
|
drawcamera_frame(local_plane, GL_LINE_LOOP);
|
|
|
|
|
|
|
|
|
|
if (v3d->stereo3d_convergence_alpha > 0.0f) {
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
|
|
|
|
|
|
|
|
|
|
glColor4f(0.0f, 0.0f, 0.0f, v3d->stereo3d_convergence_alpha);
|
|
|
|
|
|
|
|
|
|
drawcamera_frame(local_plane, GL_QUADS);
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDepthMask(1); /* restore write in zbuffer */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw convergence plane*/
|
|
|
|
|
if (is_stereo3d_volume) {
|
|
|
|
|
float screen_center[3];
|
|
|
|
|
float near_plane[4][3], far_plane[4][3];
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
mid_v3_v3v3(screen_center, vec_lr[i][0], vec_lr[i][2]);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
float offset = len_v3v3(screen_center, origin[i]);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2015-04-06 10:40:12 -03:00
|
|
|
sub_v3_v3v3(near_plane[j], vec_lr[i][j], origin[i]);
|
|
|
|
|
mul_v3_fl(near_plane[j], cam_lr[i]->clipsta / offset);
|
|
|
|
|
add_v3_v3(near_plane[j], origin[i]);
|
|
|
|
|
|
|
|
|
|
sub_v3_v3v3(far_plane[j], vec_lr[i][j], origin[i]);
|
|
|
|
|
mul_v3_fl(far_plane[j], cam_lr[i]->clipend / offset);
|
|
|
|
|
add_v3_v3(far_plane[j], origin[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* camera frame */
|
|
|
|
|
glColor3f(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
|
|
drawcamera_frame(near_plane, GL_LINE_LOOP);
|
|
|
|
|
drawcamera_frame(far_plane, GL_LINE_LOOP);
|
|
|
|
|
drawcamera_volume(near_plane, far_plane, GL_LINE_LOOP);
|
|
|
|
|
|
|
|
|
|
if (v3d->stereo3d_volume_alpha > 0.0f) {
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
glColor4f(0.0f, 1.0f, 1.0f, v3d->stereo3d_volume_alpha);
|
|
|
|
|
else
|
|
|
|
|
glColor4f(1.0f, 0.0f, 0.0f, v3d->stereo3d_volume_alpha);
|
|
|
|
|
|
|
|
|
|
drawcamera_frame(near_plane, GL_QUADS);
|
|
|
|
|
drawcamera_frame(far_plane, GL_QUADS);
|
|
|
|
|
drawcamera_volume(near_plane, far_plane, GL_QUADS);
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDepthMask(1); /* restore write in zbuffer */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* flag similar to draw_object() */
|
2012-06-06 18:00:08 +00:00
|
|
|
static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
2012-06-10 10:15:49 +00:00
|
|
|
const short dflag, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
/* a standing up pyramid with (0,0,0) as top */
|
|
|
|
|
Camera *cam;
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
2011-09-29 07:59:33 +00:00
|
|
|
float tvec[3];
|
|
|
|
|
float vec[4][3], asp[2], shift[2], scale[3];
|
2013-09-09 11:37:37 +00:00
|
|
|
MovieClip *clip = BKE_object_movieclip_get(scene, base->object, false);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2015-11-05 19:30:59 +01:00
|
|
|
const bool is_active = (ob == v3d->camera);
|
|
|
|
|
const bool is_view = (rv3d->persp == RV3D_CAMOB && is_active);
|
2015-06-22 18:23:59 +10:00
|
|
|
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
|
2015-04-06 10:40:12 -03:00
|
|
|
const bool is_stereo3d = drawcamera_is_stereo3d(scene, v3d, ob);
|
2015-06-22 15:55:36 +02:00
|
|
|
const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
|
2015-04-06 10:40:12 -03:00
|
|
|
const bool is_stereo3d_cameras = (ob == scene->camera) &&
|
2015-06-22 18:23:59 +10:00
|
|
|
is_multiview &&
|
2015-06-22 15:55:36 +02:00
|
|
|
is_stereo3d_view &&
|
2015-04-06 10:40:12 -03:00
|
|
|
(v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS);
|
2015-06-22 15:55:36 +02:00
|
|
|
const bool is_selection_camera_stereo = (G.f & G_PICKSEL) &&
|
|
|
|
|
is_view && is_multiview &&
|
|
|
|
|
is_stereo3d_view;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* draw data for movie clip set as active for scene */
|
2012-02-26 08:14:14 +00:00
|
|
|
if (clip) {
|
2013-03-24 12:13:13 +00:00
|
|
|
draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, false);
|
|
|
|
|
draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, true);
|
2012-02-26 08:14:14 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-07-21 01:30:26 +00:00
|
|
|
#ifdef VIEW3D_CAMERA_BORDER_HACK
|
2012-02-22 16:52:06 +00:00
|
|
|
if (is_view && !(G.f & G_PICKSEL)) {
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2012-06-07 15:20:51 +00:00
|
|
|
view3d_camera_border_hack_col[0] = ob_wire_col[0];
|
|
|
|
|
view3d_camera_border_hack_col[1] = ob_wire_col[1];
|
|
|
|
|
view3d_camera_border_hack_col[2] = ob_wire_col[2];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float col[4];
|
|
|
|
|
glGetFloatv(GL_CURRENT_COLOR, col);
|
|
|
|
|
rgb_float_to_uchar(view3d_camera_border_hack_col, col);
|
|
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
view3d_camera_border_hack_test = true;
|
2011-07-21 01:30:26 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
cam = ob->data;
|
2010-07-26 21:35:24 +00:00
|
|
|
|
2015-06-22 15:55:36 +02:00
|
|
|
/* BKE_camera_multiview_model_matrix already accounts for scale, don't do it here */
|
|
|
|
|
if (is_selection_camera_stereo) {
|
|
|
|
|
scale[0] = 1.0f;
|
|
|
|
|
scale[1] = 1.0f;
|
|
|
|
|
scale[2] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
scale[0] = 1.0f / len_v3(ob->obmat[0]);
|
|
|
|
|
scale[1] = 1.0f / len_v3(ob->obmat[1]);
|
|
|
|
|
scale[2] = 1.0f / len_v3(ob->obmat[2]);
|
|
|
|
|
}
|
2011-09-29 07:59:33 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
float drawsize;
|
2012-05-05 00:58:22 +00:00
|
|
|
BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale,
|
2012-05-08 15:55:29 +00:00
|
|
|
asp, shift, &drawsize, vec);
|
2011-09-29 07:59:33 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
2010-11-08 02:30:46 +00:00
|
|
|
/* camera frame */
|
2015-06-12 17:20:46 +02:00
|
|
|
if (!is_stereo3d_cameras) {
|
|
|
|
|
/* make sure selection uses the same matrix for camera as the one used while viewing */
|
2015-06-22 15:55:36 +02:00
|
|
|
if (is_selection_camera_stereo) {
|
2015-06-12 17:20:46 +02:00
|
|
|
float obmat[4][4];
|
|
|
|
|
bool is_left = v3d->multiview_eye == STEREO_LEFT_ID;
|
|
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
BKE_camera_multiview_model_matrix(&scene->r, ob, is_left ? STEREO_LEFT_NAME : STEREO_RIGHT_NAME, obmat);
|
|
|
|
|
glMultMatrixf(obmat);
|
|
|
|
|
|
|
|
|
|
drawcamera_frame(vec, GL_LINE_LOOP);
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
}
|
2015-06-22 18:23:59 +10:00
|
|
|
else {
|
2015-06-12 17:20:46 +02:00
|
|
|
drawcamera_frame(vec, GL_LINE_LOOP);
|
2015-06-22 18:23:59 +10:00
|
|
|
}
|
2015-06-12 17:20:46 +02:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (is_view)
|
2010-11-08 02:30:46 +00:00
|
|
|
return;
|
|
|
|
|
|
2011-09-29 07:59:33 +00:00
|
|
|
zero_v3(tvec);
|
|
|
|
|
|
2010-11-08 02:30:46 +00:00
|
|
|
/* center point to camera frame */
|
2015-04-06 10:40:12 -03:00
|
|
|
if (!is_stereo3d_cameras)
|
|
|
|
|
drawcamera_framelines(vec, tvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* arrow on top */
|
2012-03-25 23:54:33 +00:00
|
|
|
tvec[2] = vec[1][2]; /* copy the depth */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw an outline arrow for inactive cameras and filled
|
|
|
|
|
* for active cameras. We actually draw both outline+filled
|
2012-03-18 06:01:33 +00:00
|
|
|
* for active cameras so the wire can be seen side-on */
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (i == 0) glBegin(GL_LINE_LOOP);
|
2015-11-05 19:30:59 +01:00
|
|
|
else if (i == 1 && is_active) glBegin(GL_TRIANGLES);
|
2008-12-19 12:14:58 +00:00
|
|
|
else break;
|
2010-10-18 08:11:34 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
tvec[0] = shift[0] + ((-0.7f * drawsize) * scale[0]);
|
|
|
|
|
tvec[1] = shift[1] + ((drawsize * (asp[1] + 0.1f)) * scale[1]);
|
2011-09-29 07:59:33 +00:00
|
|
|
glVertex3fv(tvec); /* left */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
tvec[0] = shift[0] + ((0.7f * drawsize) * scale[0]);
|
2011-09-29 07:59:33 +00:00
|
|
|
glVertex3fv(tvec); /* right */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
tvec[0] = shift[0];
|
|
|
|
|
tvec[1] = shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]);
|
2011-09-29 07:59:33 +00:00
|
|
|
glVertex3fv(tvec); /* top */
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if ((dflag & DRAW_SCENESET) == 0) {
|
|
|
|
|
if (cam->flag & (CAM_SHOWLIMITS | CAM_SHOWMIST)) {
|
2010-11-08 02:30:46 +00:00
|
|
|
float nobmat[4][4];
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
/* draw in normalized object matrix space */
|
|
|
|
|
copy_m4_m4(nobmat, ob->obmat);
|
|
|
|
|
normalize_m4(nobmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glPushMatrix();
|
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
glMultMatrixf(nobmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (cam->flag & CAM_SHOWLIMITS) {
|
2015-11-05 19:30:59 +01:00
|
|
|
const unsigned char col[3] = {128, 128, 60}, col_hi[3] = {255, 255, 120};
|
|
|
|
|
|
|
|
|
|
draw_limit_line(cam->clipsta, cam->clipend, dflag, (is_active ? col_hi : col));
|
2012-03-01 12:20:18 +00:00
|
|
|
/* qdn: was yafray only, now also enabled for Blender to be used with defocus composite node */
|
2012-05-05 00:58:22 +00:00
|
|
|
draw_focus_cross(BKE_camera_object_dof_distance(ob), cam->drawsize);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (cam->flag & CAM_SHOWMIST) {
|
|
|
|
|
World *world = scene->world;
|
2015-11-05 19:30:59 +01:00
|
|
|
const unsigned char col[3] = {128, 128, 128}, col_hi[3] = {255, 255, 255};
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (world) {
|
2015-11-05 19:30:59 +01:00
|
|
|
draw_limit_line(world->miststa, world->miststa + world->mistdist,
|
|
|
|
|
dflag, (is_active ? col_hi : col));
|
2013-03-24 12:13:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-01 15:32:55 +00:00
|
|
|
glPopMatrix();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
/* stereo cameras drawing */
|
|
|
|
|
if (is_stereo3d) {
|
|
|
|
|
drawcamera_stereo3d(scene, v3d, rv3d, ob, cam, vec, drawsize, scale);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-01 11:44:20 +00:00
|
|
|
/* flag similar to draw_object() */
|
2011-12-03 20:49:41 +00:00
|
|
|
static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D *UNUSED(rv3d),
|
|
|
|
|
Object *UNUSED(ob), int UNUSED(flag))
|
2011-08-01 11:44:20 +00:00
|
|
|
{
|
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int j = 0; j < 3; j++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 0.25f * j - 0.125f;
|
2011-08-01 11:44:20 +00:00
|
|
|
|
|
|
|
|
glBegin(GL_LINE_LOOP);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2011-11-11 12:00:08 +00:00
|
|
|
vec[0] = cosf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
|
|
|
|
|
vec[1] = sinf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
|
2011-08-01 11:44:20 +00:00
|
|
|
glVertex3fv(vec);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2011-08-30 09:50:31 +00:00
|
|
|
vec[0] = (((j + 1) % 2) * (j - 1)) * 0.5f;
|
|
|
|
|
vec[1] = ((j % 2) * (j - 2)) * 0.5f;
|
2011-08-01 11:44:20 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (i == 1) {
|
2011-08-30 09:50:31 +00:00
|
|
|
vec[0] *= 0.5f;
|
|
|
|
|
vec[1] *= 0.5f;
|
2011-08-01 11:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 0.25f * i - 0.125f;
|
2011-08-01 11:44:20 +00:00
|
|
|
glVertex3fv(vec);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-09 20:28:08 +00:00
|
|
|
static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short sel)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
BPoint *bp = lt->def;
|
2014-04-27 00:22:49 +10:00
|
|
|
const float *co = dl ? dl->verts : NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-06-09 20:28:08 +00:00
|
|
|
const int color = sel ? TH_VERTEX_SELECT : TH_VERTEX;
|
|
|
|
|
UI_ThemeColor(color);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int w = 0; w < lt->pntsw; w++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
int wxt = (w == 0 || w == lt->pntsw - 1);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int v = 0; v < lt->pntsv; v++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
int vxt = (v == 0 || v == lt->pntsv - 1);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int u = 0; u < lt->pntsu; u++, bp++, co += 3) {
|
2012-03-25 23:54:33 +00:00
|
|
|
int uxt = (u == 0 || u == lt->pntsu - 1);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(lt->flag & LT_OUTSIDE) || uxt || vxt || wxt) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bp->hide == 0) {
|
2013-06-09 20:28:08 +00:00
|
|
|
/* check for active BPoint and ensure selected */
|
|
|
|
|
if ((bp == actbp) && (bp->f1 & SELECT)) {
|
2014-01-27 15:18:40 +11:00
|
|
|
UI_ThemeColor(TH_ACTIVE_VERT);
|
2013-06-09 20:28:08 +00:00
|
|
|
bglVertex3fv(dl ? co : bp->vec);
|
|
|
|
|
UI_ThemeColor(color);
|
|
|
|
|
}
|
|
|
|
|
else if ((bp->f1 & SELECT) == sel) {
|
2012-03-25 23:54:33 +00:00
|
|
|
bglVertex3fv(dl ? co : bp->vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
bglEnd();
|
2015-03-07 03:53:08 +11:00
|
|
|
glPointSize(1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int actdef_wcol)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
int index = ((w * lt->pntsv + v) * lt->pntsu) + u;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (actdef_wcol) {
|
2008-12-19 12:14:58 +00:00
|
|
|
float col[3];
|
2013-03-24 12:13:13 +00:00
|
|
|
MDeformWeight *mdw = defvert_find_index(lt->dvert + index, actdef_wcol - 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
weight_to_rgb(col, mdw ? mdw->weight : 0.0f);
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3fv(col);
|
2009-01-24 13:45:24 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dl) {
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(&dl->verts[index * 3]);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(lt->def[index].vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 14:06:13 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
static void ensure_curve_cache(Scene *scene, Object *object)
|
|
|
|
|
{
|
2014-05-28 15:28:52 +06:00
|
|
|
bool need_recalc = object->curve_cache == NULL;
|
|
|
|
|
/* Render thread might have freed the curve cache if the
|
|
|
|
|
* object is not visible. If the object is also used for
|
|
|
|
|
* particles duplication, then render thread might have
|
|
|
|
|
* also created curve_cache with only bevel and path
|
|
|
|
|
* filled in.
|
|
|
|
|
*
|
|
|
|
|
* So check for curve_cache != NULL is not fully correct
|
|
|
|
|
* here, we also need to check whether display list is
|
|
|
|
|
* empty or not.
|
|
|
|
|
*
|
2015-03-30 00:51:00 -04:00
|
|
|
* The trick below tries to optimize calls to displist
|
2014-05-28 15:28:52 +06:00
|
|
|
* creation for cases curve is empty. Meaning, if the curve
|
2015-03-30 00:51:00 -04:00
|
|
|
* is empty (without splines) bevel list would also be empty.
|
2014-05-28 15:28:52 +06:00
|
|
|
* And the thing is, render thread always leaves bevel list
|
|
|
|
|
* in a proper state. So if bevel list is here and display
|
|
|
|
|
* list is not we need to make display list.
|
|
|
|
|
*/
|
|
|
|
|
if (need_recalc == false) {
|
|
|
|
|
need_recalc = object->curve_cache->disp.first == NULL &&
|
|
|
|
|
object->curve_cache->bev.first != NULL;
|
|
|
|
|
}
|
|
|
|
|
if (need_recalc) {
|
2014-02-12 14:06:13 +06:00
|
|
|
switch (object->type) {
|
|
|
|
|
case OB_CURVE:
|
|
|
|
|
case OB_SURF:
|
|
|
|
|
case OB_FONT:
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_displist_make_curveTypes(scene, object, false);
|
2014-02-12 14:06:13 +06:00
|
|
|
break;
|
|
|
|
|
case OB_MBALL:
|
|
|
|
|
BKE_displist_make_mball(G.main->eval_ctx, scene, object);
|
|
|
|
|
break;
|
|
|
|
|
case OB_LATTICE:
|
|
|
|
|
BKE_lattice_modifiers_calc(scene, object);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* lattice color is hardcoded, now also shows weightgroup values in edit mode */
|
2014-01-13 16:33:18 +06:00
|
|
|
static void drawlattice(View3D *v3d, Object *ob)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Lattice *lt = ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
DispList *dl;
|
|
|
|
|
int u, v, w;
|
2013-03-24 12:13:13 +00:00
|
|
|
int actdef_wcol = 0;
|
|
|
|
|
const bool is_edit = (lt->editlatt != NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-08-19 09:25:24 +00:00
|
|
|
dl = BKE_displist_find(&ob->curve_cache->disp, DL_VERTS);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (is_edit) {
|
2012-03-25 23:54:33 +00:00
|
|
|
lt = lt->editlatt->latt;
|
2010-04-21 14:46:32 +00:00
|
|
|
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_ThemeColor(TH_WIRE_EDIT);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->defbase.first && lt->dvert) {
|
2013-03-24 12:13:13 +00:00
|
|
|
actdef_wcol = ob->actdef;
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
for (w = 0; w < lt->pntsw; w++) {
|
|
|
|
|
int wxt = (w == 0 || w == lt->pntsw - 1);
|
|
|
|
|
for (v = 0; v < lt->pntsv; v++) {
|
|
|
|
|
int vxt = (v == 0 || v == lt->pntsv - 1);
|
|
|
|
|
for (u = 0; u < lt->pntsu; u++) {
|
|
|
|
|
int uxt = (u == 0 || u == lt->pntsu - 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (w && ((uxt || vxt) || !(lt->flag & LT_OUTSIDE))) {
|
2013-03-24 12:13:13 +00:00
|
|
|
drawlattice__point(lt, dl, u, v, w - 1, actdef_wcol);
|
|
|
|
|
drawlattice__point(lt, dl, u, v, w, actdef_wcol);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v && ((uxt || wxt) || !(lt->flag & LT_OUTSIDE))) {
|
2013-03-24 12:13:13 +00:00
|
|
|
drawlattice__point(lt, dl, u, v - 1, w, actdef_wcol);
|
|
|
|
|
drawlattice__point(lt, dl, u, v, w, actdef_wcol);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (u && ((vxt || wxt) || !(lt->flag & LT_OUTSIDE))) {
|
2013-03-24 12:13:13 +00:00
|
|
|
drawlattice__point(lt, dl, u - 1, v, w, actdef_wcol);
|
|
|
|
|
drawlattice__point(lt, dl, u, v, w, actdef_wcol);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
/* restoration for weight colors */
|
2013-03-24 12:13:13 +00:00
|
|
|
if (actdef_wcol)
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (is_edit) {
|
2013-06-09 20:28:08 +00:00
|
|
|
BPoint *actbp = BKE_lattice_active_point_get(lt);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-06-09 20:28:08 +00:00
|
|
|
lattice_draw_verts(lt, dl, actbp, 0);
|
|
|
|
|
lattice_draw_verts(lt, dl, actbp, 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ***************** ******************** */
|
|
|
|
|
|
2011-09-18 17:10:28 +00:00
|
|
|
/* draw callback */
|
2013-06-15 11:02:36 +00:00
|
|
|
|
|
|
|
|
typedef struct drawDMVertSel_userData {
|
|
|
|
|
MVert *mvert;
|
|
|
|
|
int active;
|
|
|
|
|
unsigned char *col[3]; /* (base, sel, act) */
|
|
|
|
|
char sel_prev;
|
|
|
|
|
} drawDMVertSel_userData;
|
|
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void drawSelectedVertices__mapFunc(void *userData, int index, const float co[3],
|
|
|
|
|
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
|
2011-09-18 01:09:18 +00:00
|
|
|
{
|
2013-06-15 11:02:36 +00:00
|
|
|
drawDMVertSel_userData *data = userData;
|
|
|
|
|
MVert *mv = &data->mvert[index];
|
2011-09-19 02:43:03 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(mv->flag & ME_HIDE)) {
|
2013-06-15 11:02:36 +00:00
|
|
|
const char sel = (index == data->active) ? 2 : (mv->flag & SELECT);
|
|
|
|
|
if (sel != data->sel_prev) {
|
|
|
|
|
glColor3ubv(data->col[sel]);
|
|
|
|
|
data->sel_prev = sel;
|
2011-09-18 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glVertex3fv(co);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-18 17:10:28 +00:00
|
|
|
|
2011-09-28 05:53:40 +00:00
|
|
|
static void drawSelectedVertices(DerivedMesh *dm, Mesh *me)
|
|
|
|
|
{
|
2013-06-15 11:02:36 +00:00
|
|
|
drawDMVertSel_userData data;
|
|
|
|
|
|
|
|
|
|
/* TODO define selected color */
|
|
|
|
|
unsigned char base_col[3] = {0x0, 0x0, 0x0};
|
2013-06-15 12:11:38 +00:00
|
|
|
unsigned char sel_col[3] = {0xd8, 0xb8, 0x0};
|
2013-06-15 11:02:36 +00:00
|
|
|
unsigned char act_col[3] = {0xff, 0xff, 0xff};
|
|
|
|
|
|
|
|
|
|
data.mvert = me->mvert;
|
|
|
|
|
data.active = BKE_mesh_mselect_active_get(me, ME_VSEL);
|
|
|
|
|
data.sel_prev = 0xff;
|
|
|
|
|
|
|
|
|
|
data.col[0] = base_col;
|
|
|
|
|
data.col[1] = sel_col;
|
|
|
|
|
data.col[2] = act_col;
|
|
|
|
|
|
2011-09-18 01:09:18 +00:00
|
|
|
glBegin(GL_POINTS);
|
2013-07-22 22:59:47 +00:00
|
|
|
dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, &data, DM_FOREACH_NOP);
|
2011-09-18 01:09:18 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
2012-04-10 07:30:08 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* ************** DRAW MESH ****************** */
|
|
|
|
|
|
2012-10-11 03:25:19 +00:00
|
|
|
/* First section is all the "simple" draw routines,
|
2008-12-19 12:14:58 +00:00
|
|
|
* ones that just pass some sort of primitive to GL,
|
|
|
|
|
* with perhaps various options to control lighting,
|
|
|
|
|
* color, etc.
|
|
|
|
|
*
|
|
|
|
|
* These routines should not have user interface related
|
|
|
|
|
* logic!!!
|
|
|
|
|
*/
|
|
|
|
|
|
2012-05-01 11:01:24 +00:00
|
|
|
static void calcDrawDMNormalScale(Object *ob, drawDMNormal_userData *data)
|
|
|
|
|
{
|
|
|
|
|
float obmat[3][3];
|
|
|
|
|
|
|
|
|
|
copy_m3_m4(obmat, ob->obmat);
|
|
|
|
|
|
|
|
|
|
data->uniform_scale = is_uniform_scaled_m3(obmat);
|
|
|
|
|
|
|
|
|
|
if (!data->uniform_scale) {
|
|
|
|
|
/* inverted matrix */
|
|
|
|
|
invert_m3_m3(data->imat, obmat);
|
|
|
|
|
|
|
|
|
|
/* transposed inverted matrix */
|
2014-10-30 12:13:00 +01:00
|
|
|
transpose_m3_m3(data->tmat, data->imat);
|
2012-05-01 11:01:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void draw_dm_face_normals__mapFunc(void *userData, int index, const float cent[3], const float no[3])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-01-24 19:57:34 +00:00
|
|
|
drawDMNormal_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMFace *efa = BM_face_at_index(data->bm, index);
|
2012-05-01 11:01:24 +00:00
|
|
|
float n[3];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2012-05-01 11:01:24 +00:00
|
|
|
if (!data->uniform_scale) {
|
2013-10-12 02:19:37 +00:00
|
|
|
mul_v3_m3v3(n, data->tmat, no);
|
2012-05-01 11:01:24 +00:00
|
|
|
normalize_v3(n);
|
|
|
|
|
mul_m3_v3(data->imat, n);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(n, no);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(cent);
|
2012-05-01 11:01:24 +00:00
|
|
|
glVertex3f(cent[0] + n[0] * data->normalsize,
|
|
|
|
|
cent[1] + n[1] * data->normalsize,
|
|
|
|
|
cent[2] + n[2] * data->normalsize);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-05-01 11:01:24 +00:00
|
|
|
|
|
|
|
|
static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm)
|
2008-12-19 17:14:02 +00:00
|
|
|
{
|
2012-01-24 19:57:34 +00:00
|
|
|
drawDMNormal_userData data;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2012-01-24 19:57:34 +00:00
|
|
|
data.normalsize = scene->toolsettings->normalsize;
|
|
|
|
|
|
2012-05-01 11:01:24 +00:00
|
|
|
calcDrawDMNormalScale(ob, &data);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glBegin(GL_LINES);
|
2013-07-22 22:59:47 +00:00
|
|
|
dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void draw_dm_face_centers__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawBMSelect_userData *data = userData;
|
|
|
|
|
BMFace *efa = BM_face_at_index(data->bm, index);
|
2011-06-01 19:30:19 +00:00
|
|
|
|
2013-06-20 07:00:57 +00:00
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) &&
|
2014-06-19 18:36:49 +10:00
|
|
|
(BM_elem_flag_test(efa, BM_ELEM_SELECT) == data->select))
|
2013-06-20 07:00:57 +00:00
|
|
|
{
|
2008-12-19 12:14:58 +00:00
|
|
|
bglVertex3fv(cent);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-19 18:36:49 +10:00
|
|
|
static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, bool select)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawBMSelect_userData data = {em->bm, select};
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
bglBegin(GL_POINTS);
|
2014-06-19 18:36:49 +10:00
|
|
|
dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, &data, DM_FOREACH_NOP);
|
2008-12-19 12:14:58 +00:00
|
|
|
bglEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-01-24 19:57:34 +00:00
|
|
|
drawDMNormal_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMVert *eve = BM_vert_at_index(data->bm, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
|
2012-05-01 11:01:24 +00:00
|
|
|
float no[3], n[3];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
if (no_f) {
|
2012-05-01 11:01:24 +00:00
|
|
|
copy_v3_v3(no, no_f);
|
2012-01-24 19:57:34 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-06-11 05:56:02 +00:00
|
|
|
normal_short_to_float_v3(no, no_s);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-05-01 11:01:24 +00:00
|
|
|
|
|
|
|
|
if (!data->uniform_scale) {
|
2013-10-12 02:19:37 +00:00
|
|
|
mul_v3_m3v3(n, data->tmat, no);
|
2012-05-01 11:01:24 +00:00
|
|
|
normalize_v3(n);
|
|
|
|
|
mul_m3_v3(data->imat, n);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(n, no);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glVertex3fv(co);
|
|
|
|
|
glVertex3f(co[0] + n[0] * data->normalsize,
|
|
|
|
|
co[1] + n[1] * data->normalsize,
|
|
|
|
|
co[2] + n[2] * data->normalsize);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-05-01 11:01:24 +00:00
|
|
|
|
|
|
|
|
static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm)
|
2008-12-19 17:14:02 +00:00
|
|
|
{
|
2012-01-24 19:57:34 +00:00
|
|
|
drawDMNormal_userData data;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2012-01-24 19:57:34 +00:00
|
|
|
data.normalsize = scene->toolsettings->normalsize;
|
|
|
|
|
|
2012-05-01 11:01:24 +00:00
|
|
|
calcDrawDMNormalScale(ob, &data);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glBegin(GL_LINES);
|
2013-07-22 22:59:47 +00:00
|
|
|
dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-12 01:55:08 +00:00
|
|
|
/* Draw verts with color set based on selection */
|
2012-04-09 07:06:06 +00:00
|
|
|
static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3],
|
|
|
|
|
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
drawDMVerts_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMVert *eve = BM_vert_at_index(data->bm, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* skin nodes: draw a red circle around the root node(s) */
|
2013-06-20 11:18:19 +00:00
|
|
|
if (data->cd_vskin_offset != -1) {
|
|
|
|
|
const MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, data->cd_vskin_offset);
|
2012-05-22 15:29:27 +00:00
|
|
|
if (vs->flag & MVERT_SKIN_ROOT) {
|
|
|
|
|
float radius = (vs->radius[0] + vs->radius[1]) * 0.5f;
|
|
|
|
|
bglEnd();
|
|
|
|
|
|
|
|
|
|
glColor4ubv(data->th_skin_root);
|
|
|
|
|
drawcircball(GL_LINES, co, radius, data->imat);
|
|
|
|
|
|
|
|
|
|
glColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex);
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw active larger - need to stop/start point drawing for this :/ */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (eve == data->eve_act) {
|
2012-05-22 15:29:27 +00:00
|
|
|
glColor4ubv(data->th_editmesh_active);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
bglEnd();
|
|
|
|
|
|
2012-05-22 15:29:27 +00:00
|
|
|
glPointSize(data->th_vertex_size);
|
2008-12-19 12:14:58 +00:00
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
bglVertex3fv(co);
|
|
|
|
|
bglEnd();
|
2012-05-22 15:29:27 +00:00
|
|
|
|
|
|
|
|
glColor4ubv(data->sel ? data->th_vertex_select : data->th_vertex);
|
|
|
|
|
glPointSize(data->th_vertex_size);
|
2008-12-19 12:14:58 +00:00
|
|
|
bglBegin(GL_POINTS);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
bglVertex3fv(co);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-05 17:29:56 +00:00
|
|
|
|
2013-06-11 05:56:02 +00:00
|
|
|
static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, const char sel, BMVert *eve_act,
|
2012-06-06 14:48:39 +00:00
|
|
|
RegionView3D *rv3d)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawDMVerts_userData data;
|
2008-12-19 12:14:58 +00:00
|
|
|
data.sel = sel;
|
|
|
|
|
data.eve_act = eve_act;
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2012-05-22 15:29:27 +00:00
|
|
|
/* Cache theme values */
|
|
|
|
|
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, data.th_editmesh_active);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_VERTEX_SELECT, data.th_vertex_select);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_VERTEX, data.th_vertex);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_SKIN_ROOT, data.th_skin_root);
|
|
|
|
|
data.th_vertex_size = UI_GetThemeValuef(TH_VERTEX_SIZE);
|
|
|
|
|
|
|
|
|
|
/* For skin root drawing */
|
2013-06-20 11:18:19 +00:00
|
|
|
data.cd_vskin_offset = CustomData_get_offset(&em->bm->vdata, CD_MVERT_SKIN);
|
2012-05-22 15:29:27 +00:00
|
|
|
/* view-aligned matrix */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(data.imat, rv3d->viewmat, em->ob->obmat);
|
2012-05-22 15:29:27 +00:00
|
|
|
invert_m4(data.imat);
|
|
|
|
|
|
2010-01-08 17:53:17 +00:00
|
|
|
bglBegin(GL_POINTS);
|
2013-07-22 22:59:47 +00:00
|
|
|
dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data, DM_FOREACH_NOP);
|
2010-01-08 17:53:17 +00:00
|
|
|
bglEnd();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* Draw edges with color set based on selection */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2009-05-16 16:18:08 +00:00
|
|
|
BMEdge *eed;
|
2012-03-25 23:54:33 +00:00
|
|
|
drawDMEdgesSel_userData *data = userData;
|
2008-12-19 12:14:58 +00:00
|
|
|
unsigned char *col;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
eed = BM_edge_at_index(data->bm, index);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (eed == data->eed_act) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor4ubv(data->actCol);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-02-12 10:51:45 +00:00
|
|
|
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
col = data->selCol;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
col = data->baseCol;
|
|
|
|
|
}
|
2015-03-30 00:51:00 -04:00
|
|
|
/* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (col[3] == 0)
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glColor4ubv(col);
|
|
|
|
|
}
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-12-16 01:24:15 -05:00
|
|
|
|
2012-10-11 03:25:19 +00:00
|
|
|
static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
|
2012-03-18 06:01:33 +00:00
|
|
|
unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawDMEdgesSel_userData data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
data.baseCol = baseCol;
|
|
|
|
|
data.selCol = selCol;
|
|
|
|
|
data.actCol = actCol;
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2008-12-19 12:14:58 +00:00
|
|
|
data.eed_act = eed_act;
|
|
|
|
|
dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* Draw edges */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
if (BM_elem_flag_test(BM_edge_at_index(userData, index), BM_ELEM_HIDDEN))
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
|
|
|
|
else
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-08 06:47:05 +00:00
|
|
|
|
2012-10-11 03:25:19 +00:00
|
|
|
static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em->bm);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* Draw edges with color interpolated based on selection */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawDMEdgesSelInterp_userData *data = userData;
|
|
|
|
|
if (BM_elem_flag_test(BM_edge_at_index(data->bm, index), BM_ELEM_HIDDEN))
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
|
|
|
|
else
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t)
|
|
|
|
|
{
|
2014-06-04 20:40:42 +10:00
|
|
|
drawDMEdgesSelInterp_userData *data = userData;
|
2014-06-19 18:36:49 +10:00
|
|
|
BMEdge *eed = BM_edge_at_index(data->bm, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
unsigned char **cols = userData;
|
2014-06-04 20:40:42 +10:00
|
|
|
unsigned int col0_id = (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1;
|
|
|
|
|
unsigned int col1_id = (BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1;
|
|
|
|
|
unsigned char *col0 = cols[col0_id];
|
|
|
|
|
unsigned char *col1 = cols[col1_id];
|
|
|
|
|
unsigned char *col_pt;
|
|
|
|
|
|
|
|
|
|
if (col0_id == col1_id) {
|
|
|
|
|
col_pt = col0;
|
|
|
|
|
}
|
|
|
|
|
else if (t == 0.0f) {
|
|
|
|
|
col_pt = col0;
|
|
|
|
|
}
|
|
|
|
|
else if (t == 1.0f) {
|
|
|
|
|
col_pt = col1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
unsigned char col_blend[4];
|
|
|
|
|
interp_v4_v4v4_uchar(col_blend, col0, col1, t);
|
|
|
|
|
glColor4ubv(col_blend);
|
|
|
|
|
data->lastCol = NULL;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-06-04 20:40:42 +10:00
|
|
|
if (data->lastCol != col_pt) {
|
|
|
|
|
data->lastCol = col_pt;
|
|
|
|
|
glColor4ubv(col_pt);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-04 20:40:42 +10:00
|
|
|
drawDMEdgesSelInterp_userData data;
|
|
|
|
|
data.bm = em->bm;
|
|
|
|
|
data.baseCol = baseCol;
|
|
|
|
|
data.selCol = selCol;
|
|
|
|
|
data.lastCol = NULL;
|
2010-01-08 17:53:17 +00:00
|
|
|
|
2014-06-04 20:40:42 +10:00
|
|
|
dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, &data);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-19 04:01:19 +10:00
|
|
|
static void bm_color_from_weight(float col[3], BMVert *vert, drawDMEdgesWeightInterp_userData *data)
|
|
|
|
|
{
|
|
|
|
|
MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(vert, data->cd_dvert_offset);
|
|
|
|
|
float weight = defvert_find_weight(dvert, data->vgroup_index);
|
|
|
|
|
|
|
|
|
|
if ((weight == 0.0f) &&
|
|
|
|
|
((data->weight_user == OB_DRAW_GROUPUSER_ACTIVE) ||
|
|
|
|
|
((data->weight_user == OB_DRAW_GROUPUSER_ALL) && defvert_is_weight_zero(dvert, data->defgroup_tot))))
|
|
|
|
|
{
|
|
|
|
|
copy_v3_v3(col, data->alert_color);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
weight_to_rgb(col, weight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-19 22:34:52 +10:00
|
|
|
static void draw_dm_edges_nop_interp__setDrawInterpOptions(void *UNUSED(userData), int UNUSED(index), float UNUSED(t))
|
|
|
|
|
{
|
|
|
|
|
/* pass */
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-19 04:01:19 +10:00
|
|
|
static void draw_dm_edges_weight_interp__setDrawInterpOptions(void *userData, int index, float t)
|
|
|
|
|
{
|
|
|
|
|
drawDMEdgesWeightInterp_userData *data = userData;
|
2014-06-19 04:17:38 +10:00
|
|
|
BMEdge *eed = BM_edge_at_index(data->bm, index);
|
2014-06-19 04:01:19 +10:00
|
|
|
float col[3];
|
|
|
|
|
|
|
|
|
|
if (t == 0.0f) {
|
|
|
|
|
bm_color_from_weight(col, eed->v1, data);
|
|
|
|
|
}
|
|
|
|
|
else if (t == 1.0f) {
|
|
|
|
|
bm_color_from_weight(col, eed->v2, data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float col_v1[3];
|
|
|
|
|
float col_v2[3];
|
|
|
|
|
|
|
|
|
|
bm_color_from_weight(col_v1, eed->v1, data);
|
|
|
|
|
bm_color_from_weight(col_v2, eed->v2, data);
|
|
|
|
|
interp_v3_v3v3(col, col_v1, col_v2, t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glColor3fv(col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void draw_dm_edges_weight_interp(BMEditMesh *em, DerivedMesh *dm, const char weight_user)
|
|
|
|
|
{
|
|
|
|
|
drawDMEdgesWeightInterp_userData data;
|
|
|
|
|
Object *ob = em->ob;
|
|
|
|
|
|
2014-06-19 04:17:38 +10:00
|
|
|
data.bm = em->bm;
|
2014-06-19 04:01:19 +10:00
|
|
|
data.cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
|
2014-11-16 13:57:58 +01:00
|
|
|
data.defgroup_tot = BLI_listbase_count(&ob->defbase);
|
2014-06-19 04:01:19 +10:00
|
|
|
data.vgroup_index = ob->actdef - 1;
|
|
|
|
|
data.weight_user = weight_user;
|
|
|
|
|
UI_GetThemeColor3fv(TH_VERTEX_UNREFERENCED, data.alert_color);
|
|
|
|
|
|
2014-06-19 22:34:52 +10:00
|
|
|
if ((data.vgroup_index != -1) && (data.cd_dvert_offset != -1)) {
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
dm->drawMappedEdgesInterp(
|
|
|
|
|
dm,
|
|
|
|
|
draw_dm_edges_sel_interp__setDrawOptions,
|
|
|
|
|
draw_dm_edges_weight_interp__setDrawInterpOptions,
|
|
|
|
|
&data);
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float col[3];
|
|
|
|
|
|
|
|
|
|
if (data.weight_user == OB_DRAW_GROUPUSER_NONE) {
|
|
|
|
|
weight_to_rgb(col, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(col, data.alert_color);
|
|
|
|
|
}
|
|
|
|
|
glColor3fv(col);
|
|
|
|
|
|
|
|
|
|
dm->drawMappedEdgesInterp(
|
|
|
|
|
dm,
|
|
|
|
|
draw_dm_edges_sel_interp__setDrawOptions,
|
|
|
|
|
draw_dm_edges_nop_interp__setDrawInterpOptions,
|
|
|
|
|
&data);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-19 04:01:19 +10:00
|
|
|
}
|
|
|
|
|
|
2014-06-19 22:34:52 +10:00
|
|
|
static bool draw_dm_edges_weight_check(Mesh *me, View3D *v3d)
|
2014-06-19 04:01:19 +10:00
|
|
|
{
|
2014-06-19 22:34:52 +10:00
|
|
|
if (me->drawflag & ME_DRAWEIGHT) {
|
2014-06-19 04:01:19 +10:00
|
|
|
if ((v3d->drawtype == OB_WIRE) ||
|
|
|
|
|
(v3d->flag2 & V3D_SOLID_MATCAP) ||
|
|
|
|
|
((v3d->flag2 & V3D_OCCLUDE_WIRE) && (v3d->drawtype > OB_WIRE)))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* Draw only seam edges */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
BMEdge *eed = BM_edge_at_index(userData, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM))
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
else
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-05-18 08:46:04 +00:00
|
|
|
static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-10-28 23:35:25 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em->bm);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* Draw only sharp edges */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
BMEdge *eed = BM_edge_at_index(userData, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && !BM_elem_flag_test(eed, BM_ELEM_SMOOTH))
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
else
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-08 06:47:05 +00:00
|
|
|
|
2009-05-18 08:46:04 +00:00
|
|
|
static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-10-28 23:35:25 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em->bm);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-03-13 06:44:43 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
static bool draw_dm_test_freestyle_edge_mark(BMesh *bm, BMEdge *eed)
|
2013-03-13 06:44:43 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, eed->head.data, CD_FREESTYLE_EDGE);
|
2013-03-13 06:44:43 +00:00
|
|
|
if (!fed)
|
2015-12-16 01:24:15 -05:00
|
|
|
return false;
|
2013-03-13 06:44:43 +00:00
|
|
|
return (fed->flag & FREESTYLE_EDGE_MARK) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 08:20:19 +00:00
|
|
|
/* Draw only Freestyle feature edges */
|
2012-03-31 22:09:43 +00:00
|
|
|
static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index)
|
2011-10-06 02:04:43 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
BMEdge *eed = BM_edge_at_index(userData, index);
|
2011-10-06 02:04:43 +00:00
|
|
|
|
2013-03-13 06:44:43 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && draw_dm_test_freestyle_edge_mark(userData, eed))
|
2012-03-31 22:09:43 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
else
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2011-10-06 02:04:43 +00:00
|
|
|
}
|
2012-03-31 22:09:43 +00:00
|
|
|
|
2012-02-21 01:40:04 +00:00
|
|
|
static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm)
|
2011-10-06 02:04:43 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em->bm);
|
2011-10-06 02:04:43 +00:00
|
|
|
}
|
2013-03-13 06:44:43 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
static bool draw_dm_test_freestyle_face_mark(BMesh *bm, BMFace *efa)
|
2013-03-13 06:44:43 +00:00
|
|
|
{
|
2013-10-28 02:05:33 +00:00
|
|
|
FreestyleFace *ffa = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_FREESTYLE_FACE);
|
2013-03-13 06:44:43 +00:00
|
|
|
if (!ffa)
|
2015-12-16 01:24:15 -05:00
|
|
|
return false;
|
2013-03-13 06:44:43 +00:00
|
|
|
return (ffa->flag & FREESTYLE_FACE_MARK) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-04-13 12:18:51 +02:00
|
|
|
/* Draw loop normals. */
|
2014-04-23 15:18:11 +02:00
|
|
|
static void draw_dm_loop_normals__mapFunc(void *userData, int vertex_index, int face_index,
|
|
|
|
|
const float co[3], const float no[3])
|
2014-04-13 12:18:51 +02:00
|
|
|
{
|
2014-04-23 15:18:11 +02:00
|
|
|
if (no) {
|
|
|
|
|
const drawDMNormal_userData *data = userData;
|
|
|
|
|
const BMVert *eve = BM_vert_at_index(data->bm, vertex_index);
|
|
|
|
|
const BMFace *efa = BM_face_at_index(data->bm, face_index);
|
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
if (!(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) || BM_elem_flag_test(efa, BM_ELEM_HIDDEN))) {
|
|
|
|
|
if (!data->uniform_scale) {
|
2014-04-24 02:34:34 +10:00
|
|
|
mul_v3_m3v3(vec, (float(*)[3])data->tmat, no);
|
2014-04-23 15:18:11 +02:00
|
|
|
normalize_v3(vec);
|
2014-04-24 02:34:34 +10:00
|
|
|
mul_m3_v3((float(*)[3])data->imat, vec);
|
2014-04-13 12:18:51 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2014-04-23 15:18:11 +02:00
|
|
|
copy_v3_v3(vec, no);
|
2014-04-13 12:18:51 +02:00
|
|
|
}
|
2014-04-23 15:18:11 +02:00
|
|
|
mul_v3_fl(vec, data->normalsize);
|
|
|
|
|
add_v3_v3(vec, co);
|
2014-04-13 12:18:51 +02:00
|
|
|
glVertex3fv(co);
|
2014-04-23 15:18:11 +02:00
|
|
|
glVertex3fv(vec);
|
2014-04-13 12:18:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 15:18:11 +02:00
|
|
|
static void draw_dm_loop_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
drawDMNormal_userData data;
|
|
|
|
|
|
|
|
|
|
data.bm = em->bm;
|
|
|
|
|
data.normalsize = scene->toolsettings->normalsize;
|
|
|
|
|
|
|
|
|
|
calcDrawDMNormalScale(ob, &data);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
dm->foreachMappedLoop(dm, draw_dm_loop_normals__mapFunc, &data, DM_FOREACH_USE_NORMAL);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
/* Draw faces with color set based on selection
|
2012-03-25 23:54:33 +00:00
|
|
|
* return 2 for the active face so it renders with stipple enabled */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
drawDMFacesSel_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMFace *efa = BM_face_at_index(data->bm, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
unsigned char *col;
|
|
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
if (efa == data->efa_act) {
|
2013-05-27 13:03:33 +00:00
|
|
|
glColor4ubv(data->cols[2]);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_STIPPLE;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-10-28 02:05:33 +00:00
|
|
|
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0];
|
2012-12-20 07:57:26 +00:00
|
|
|
#else
|
|
|
|
|
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
|
|
|
|
|
#endif
|
2012-03-25 23:54:33 +00:00
|
|
|
if (col[3] == 0)
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor4ubv(col);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-29 16:07:44 +00:00
|
|
|
static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index)
|
|
|
|
|
{
|
2011-12-10 05:38:00 +00:00
|
|
|
|
2011-12-20 08:47:36 +00:00
|
|
|
drawDMFacesSel_userData *data = userData;
|
2013-06-20 07:00:57 +00:00
|
|
|
int i;
|
2011-12-02 01:01:07 +00:00
|
|
|
BMFace *efa;
|
|
|
|
|
BMFace *next_efa;
|
|
|
|
|
|
2011-08-29 16:07:44 +00:00
|
|
|
unsigned char *col, *next_col;
|
|
|
|
|
|
2015-07-18 00:01:44 +10:00
|
|
|
i = data->orig_index_mp_to_orig ? data->orig_index_mp_to_orig[index] : index;
|
2013-10-28 02:05:33 +00:00
|
|
|
efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL;
|
2015-07-18 00:01:44 +10:00
|
|
|
i = data->orig_index_mp_to_orig ? data->orig_index_mp_to_orig[next_index] : next_index;
|
2013-10-28 02:05:33 +00:00
|
|
|
next_efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL;
|
2013-06-20 07:00:57 +00:00
|
|
|
|
|
|
|
|
if (ELEM(NULL, efa, next_efa))
|
|
|
|
|
return 0;
|
2011-12-01 18:26:48 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (efa == next_efa)
|
2011-08-29 16:07:44 +00:00
|
|
|
return 1;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (efa == data->efa_act || next_efa == data->efa_act)
|
2011-08-29 16:07:44 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-10-28 02:05:33 +00:00
|
|
|
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0];
|
|
|
|
|
next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0];
|
2012-12-20 07:57:26 +00:00
|
|
|
#else
|
|
|
|
|
col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0];
|
|
|
|
|
next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0];
|
|
|
|
|
#endif
|
2011-08-29 16:07:44 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (col[3] == 0 || next_col[3] == 0)
|
2011-08-29 16:07:44 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return col == next_col;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* also draws the active face */
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2012-10-11 03:25:19 +00:00
|
|
|
static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
|
2012-12-20 07:57:26 +00:00
|
|
|
unsigned char *selCol, unsigned char *actCol, unsigned char *markCol, BMFace *efa_act)
|
|
|
|
|
#else
|
|
|
|
|
static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol,
|
|
|
|
|
unsigned char *selCol, unsigned char *actCol, BMFace *efa_act)
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2011-12-20 08:47:36 +00:00
|
|
|
drawDMFacesSel_userData data;
|
2012-03-25 23:54:33 +00:00
|
|
|
data.dm = dm;
|
2008-12-19 12:14:58 +00:00
|
|
|
data.cols[0] = baseCol;
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2008-12-19 12:14:58 +00:00
|
|
|
data.cols[1] = selCol;
|
2012-12-20 07:57:26 +00:00
|
|
|
data.cols[2] = actCol;
|
|
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
|
data.cols[3] = markCol;
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
data.efa_act = efa_act;
|
2012-10-30 19:20:17 +00:00
|
|
|
/* double lookup */
|
|
|
|
|
data.orig_index_mp_to_orig = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2015-07-25 20:00:49 +02:00
|
|
|
dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, NULL, draw_dm_faces_sel__compareDrawOptions, &data, DM_DRAW_SKIP_HIDDEN);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-06-20 11:18:19 +00:00
|
|
|
drawDMLayer_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm = data->bm;
|
|
|
|
|
BMEdge *eed = BM_edge_at_index(bm, index);
|
2010-07-14 22:06:10 +00:00
|
|
|
|
2013-06-20 11:18:19 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
|
|
|
|
|
const float crease = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset);
|
|
|
|
|
if (crease != 0.0f) {
|
|
|
|
|
UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_CREASE, crease);
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-06-20 11:18:19 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-05-18 08:46:04 +00:00
|
|
|
static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-06-20 11:18:19 +00:00
|
|
|
drawDMLayer_userData data;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2013-06-20 11:18:19 +00:00
|
|
|
data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE);
|
|
|
|
|
|
|
|
|
|
if (data.cd_layer_offset != -1) {
|
|
|
|
|
glLineWidth(3.0);
|
|
|
|
|
dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, &data);
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-06-20 11:18:19 +00:00
|
|
|
drawDMLayer_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm = data->bm;
|
|
|
|
|
BMEdge *eed = BM_edge_at_index(bm, index);
|
2013-06-20 11:18:19 +00:00
|
|
|
|
2013-06-20 07:00:57 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
|
2013-06-20 11:18:19 +00:00
|
|
|
const float bweight = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset);
|
|
|
|
|
if (bweight != 0.0f) {
|
|
|
|
|
UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_SELECT, bweight);
|
2013-06-20 07:00:57 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-06-20 07:00:57 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-04-09 07:06:06 +00:00
|
|
|
static void draw_dm_bweights__mapFunc(void *userData, int index, const float co[3],
|
|
|
|
|
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-06-20 11:18:19 +00:00
|
|
|
drawDMLayer_userData *data = userData;
|
2013-10-28 02:05:33 +00:00
|
|
|
BMesh *bm = data->bm;
|
|
|
|
|
BMVert *eve = BM_vert_at_index(bm, index);
|
2013-06-20 07:00:57 +00:00
|
|
|
|
|
|
|
|
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
|
2013-06-20 11:18:19 +00:00
|
|
|
const float bweight = BM_ELEM_CD_GET_FLOAT(eve, data->cd_layer_offset);
|
|
|
|
|
if (bweight != 0.0f) {
|
|
|
|
|
UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, bweight);
|
2013-06-20 07:00:57 +00:00
|
|
|
bglVertex3fv(co);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-05-18 08:46:04 +00:00
|
|
|
static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
ToolSettings *ts = scene->toolsettings;
|
2009-06-23 00:41:55 +00:00
|
|
|
|
|
|
|
|
if (ts->selectmode & SCE_SELECT_VERTEX) {
|
2013-06-20 11:18:19 +00:00
|
|
|
drawDMLayer_userData data;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2013-06-20 11:18:19 +00:00
|
|
|
data.cd_layer_offset = CustomData_get_offset(&em->bm->vdata, CD_BWEIGHT);
|
|
|
|
|
|
|
|
|
|
if (data.cd_layer_offset != -1) {
|
2013-06-20 07:00:57 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2);
|
|
|
|
|
bglBegin(GL_POINTS);
|
2013-07-22 22:59:47 +00:00
|
|
|
dm->foreachMappedVert(dm, draw_dm_bweights__mapFunc, &data, DM_FOREACH_NOP);
|
2013-06-20 07:00:57 +00:00
|
|
|
bglEnd();
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-06-20 11:18:19 +00:00
|
|
|
drawDMLayer_userData data;
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
data.bm = em->bm;
|
2013-06-20 11:18:19 +00:00
|
|
|
data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT);
|
|
|
|
|
|
|
|
|
|
if (data.cd_layer_offset != -1) {
|
2013-06-20 07:00:57 +00:00
|
|
|
glLineWidth(3.0);
|
2013-06-20 11:18:19 +00:00
|
|
|
dm->drawMappedEdges(dm, draw_dm_bweights__setDrawOptions, &data);
|
2013-06-20 07:00:57 +00:00
|
|
|
glLineWidth(1.0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Second section of routines: Combine first sets to form fancy
|
|
|
|
|
* drawing routines (for example rendering twice to get overlays).
|
|
|
|
|
*
|
|
|
|
|
* Also includes routines that are basic drawing but are too
|
|
|
|
|
* specialized to be split out (like drawing creases or measurements).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* EditMesh drawing routines*/
|
|
|
|
|
|
2012-10-11 03:25:19 +00:00
|
|
|
static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit,
|
2012-05-22 15:29:27 +00:00
|
|
|
BMEditMesh *em, DerivedMesh *cageDM, BMVert *eve_act,
|
2012-10-11 03:25:19 +00:00
|
|
|
RegionView3D *rv3d)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
ToolSettings *ts = scene->toolsettings;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
if (v3d->zbuf) glDepthMask(0); /* disable write in zbuffer, zbuf select */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int sel = 0; sel < 2; sel++) {
|
2010-12-20 03:59:22 +00:00
|
|
|
unsigned char col[4], fcol[4];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
UI_GetThemeColor3ubv(sel ? TH_VERTEX_SELECT : TH_VERTEX, col);
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_GetThemeColor3ubv(sel ? TH_FACE_DOT : TH_WIRE_EDIT, fcol);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int pass = 0; pass < 2; pass++) {
|
2008-12-19 12:14:58 +00:00
|
|
|
float size = UI_GetThemeValuef(TH_VERTEX_SIZE);
|
|
|
|
|
float fsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pass == 0) {
|
|
|
|
|
if (v3d->zbuf && !(v3d->flag & V3D_ZBUF_SELECT)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
glEnable(GL_BLEND);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
size = (size > 2.1f ? size / 2.0f : size);
|
|
|
|
|
fsize = (fsize > 2.1f ? fsize / 2.0f : fsize);
|
2008-12-19 12:14:58 +00:00
|
|
|
col[3] = fcol[3] = 100;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
col[3] = fcol[3] = 255;
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ts->selectmode & SCE_SELECT_VERTEX) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(size);
|
2010-12-20 03:59:22 +00:00
|
|
|
glColor4ubv(col);
|
2012-05-22 15:29:27 +00:00
|
|
|
draw_dm_verts(em, cageDM, sel, eve_act, rv3d);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (check_ob_drawface_dot(scene, v3d, obedit->dt)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(fsize);
|
2010-12-20 03:59:22 +00:00
|
|
|
glColor4ubv(fcol);
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_face_centers(em, cageDM, sel);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pass == 0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->zbuf) glDepthMask(1);
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-04 23:13:28 +00:00
|
|
|
static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d,
|
2011-12-04 23:04:43 +00:00
|
|
|
Mesh *me, DerivedMesh *cageDM, short sel_only,
|
2011-12-04 23:13:28 +00:00
|
|
|
BMEdge *eed_act)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
ToolSettings *ts = scene->toolsettings;
|
2008-12-19 12:14:58 +00:00
|
|
|
unsigned char wireCol[4], selCol[4], actCol[4];
|
|
|
|
|
|
2012-07-16 23:23:33 +00:00
|
|
|
/* since this function does transparent... */
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_EDGE_SELECT, selCol);
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_WIRE_EDIT, wireCol);
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, actCol);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* when sel only is used, don't render wire, only selected, this is used for
|
2008-12-19 12:14:58 +00:00
|
|
|
* textured draw mode when the 'edges' option is disabled */
|
|
|
|
|
if (sel_only)
|
|
|
|
|
wireCol[3] = 0;
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int pass = 0; pass < 2; pass++) {
|
2012-07-16 23:23:33 +00:00
|
|
|
/* show wires in transparent when no zbuf clipping for select */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pass == 0) {
|
|
|
|
|
if (v3d->zbuf && (v3d->flag & V3D_ZBUF_SELECT) == 0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
selCol[3] = 85;
|
|
|
|
|
if (!sel_only) wireCol[3] = 85;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-12-19 12:14:58 +00:00
|
|
|
selCol[3] = 255;
|
|
|
|
|
if (!sel_only) wireCol[3] = 255;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-26 16:53:40 +01:00
|
|
|
if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) {
|
2014-06-19 04:01:19 +10:00
|
|
|
if (cageDM->drawMappedEdgesInterp &&
|
|
|
|
|
((ts->selectmode & SCE_SELECT_VERTEX) || (me->drawflag & ME_DRAWEIGHT)))
|
|
|
|
|
{
|
2014-06-19 22:34:52 +10:00
|
|
|
if (draw_dm_edges_weight_check(me, v3d)) {
|
2014-12-26 16:53:40 +01:00
|
|
|
glShadeModel(GL_SMOOTH);
|
2014-06-19 04:01:19 +10:00
|
|
|
draw_dm_edges_weight_interp(em, cageDM, ts->weightuser);
|
2014-12-26 16:53:40 +01:00
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
}
|
|
|
|
|
else if (ts->selectmode == SCE_SELECT_FACE) {
|
|
|
|
|
draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act);
|
2014-06-19 04:01:19 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2014-12-26 16:53:40 +01:00
|
|
|
glShadeModel(GL_SMOOTH);
|
2014-06-19 04:01:19 +10:00
|
|
|
draw_dm_edges_sel_interp(em, cageDM, wireCol, selCol);
|
2014-12-26 16:53:40 +01:00
|
|
|
glShadeModel(GL_FLAT);
|
2014-06-19 04:01:19 +10:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!sel_only) {
|
|
|
|
|
glColor4ubv(wireCol);
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_edges(em, cageDM);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pass == 0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-11 03:25:19 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-05-31 23:52:39 +00:00
|
|
|
static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-11-08 11:25:50 +00:00
|
|
|
/* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.).
|
|
|
|
|
* See bug #36090.
|
|
|
|
|
*/
|
|
|
|
|
const short txt_flag = V3D_CACHE_TEXT_LOCALCLIP | (unit->system ? 0 : V3D_CACHE_TEXT_ASCII);
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = ob->data;
|
2011-06-24 00:55:14 +00:00
|
|
|
float v1[3], v2[3], v3[3], vmid[3], fvec[3];
|
2012-01-11 09:33:44 +00:00
|
|
|
char numstr[32]; /* Stores the measurement display text here */
|
2014-04-17 15:14:07 +10:00
|
|
|
size_t numstr_len;
|
2010-12-20 03:59:22 +00:00
|
|
|
const char *conv_float; /* Use a float conversion matching the grid size */
|
2012-03-25 23:54:33 +00:00
|
|
|
unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */
|
2010-12-20 03:59:22 +00:00
|
|
|
float area; /* area of the face */
|
2012-03-25 23:54:33 +00:00
|
|
|
float grid = unit->system ? unit->scale_length : v3d->grid;
|
2013-03-29 04:01:52 +00:00
|
|
|
const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
|
|
|
|
|
const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
|
2013-06-24 22:41:37 +00:00
|
|
|
const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0;
|
2014-01-15 20:03:19 +11:00
|
|
|
/* when 2 edge-info options are enabled, space apart */
|
|
|
|
|
const bool do_edge_textpair = (me->drawflag & ME_DRAWEXTRA_EDGELEN) && (me->drawflag & ME_DRAWEXTRA_EDGEANG);
|
|
|
|
|
const float edge_texpair_sep = 0.4f;
|
2013-05-31 23:52:39 +00:00
|
|
|
float clip_planes[4][4];
|
2013-07-09 12:59:31 +00:00
|
|
|
/* allow for displaying shape keys and deform mods */
|
2013-07-10 02:05:16 +00:00
|
|
|
DerivedMesh *dm = EDBM_mesh_deform_dm_get(em);
|
2011-06-24 00:55:14 +00:00
|
|
|
BMIter iter;
|
|
|
|
|
|
2012-12-02 15:58:26 +00:00
|
|
|
/* make the precision of the display value proportionate to the gridsize */
|
2009-08-16 11:16:04 +00:00
|
|
|
|
2012-12-26 14:22:04 +00:00
|
|
|
if (grid <= 0.01f) conv_float = "%.6g";
|
|
|
|
|
else if (grid <= 0.1f) conv_float = "%.5g";
|
|
|
|
|
else if (grid <= 1.0f) conv_float = "%.4g";
|
|
|
|
|
else if (grid <= 10.0f) conv_float = "%.3g";
|
2012-03-25 23:54:33 +00:00
|
|
|
else conv_float = "%.2g";
|
2013-05-31 23:52:39 +00:00
|
|
|
|
|
|
|
|
if (me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_EDGEANG)) {
|
|
|
|
|
BoundBox bb;
|
|
|
|
|
bglMats mats = {{0}};
|
|
|
|
|
const rcti rect = {0, ar->winx, 0, ar->winy};
|
|
|
|
|
|
|
|
|
|
view3d_get_transformation(ar, ar->regiondata, em->ob, &mats);
|
|
|
|
|
ED_view3d_clipping_calc(&bb, clip_planes, &mats, &rect);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWEXTRA_EDGELEN) {
|
2011-06-24 00:55:14 +00:00
|
|
|
BMEdge *eed;
|
|
|
|
|
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
|
|
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* draw selected edges, or edges next to selected verts while dragging */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
|
2012-02-28 13:03:56 +00:00
|
|
|
(do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
|
|
|
|
|
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))))
|
|
|
|
|
{
|
2013-07-09 12:59:31 +00:00
|
|
|
float v1_clip[3], v2_clip[3];
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(eed->v1), v1);
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(eed->v2), v2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(v1, eed->v1->co);
|
|
|
|
|
copy_v3_v3(v2, eed->v2->co);
|
|
|
|
|
}
|
2010-07-26 18:20:20 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
copy_v3_v3(v1_clip, v1);
|
|
|
|
|
copy_v3_v3(v2_clip, v2);
|
2010-07-26 18:20:20 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (clip_segment_v3_plane_n(v1_clip, v2_clip, clip_planes, 4)) {
|
2012-01-19 16:04:44 +00:00
|
|
|
|
2014-01-15 20:03:19 +11:00
|
|
|
if (do_edge_textpair) {
|
|
|
|
|
interp_v3_v3v3(vmid, v1, v2, edge_texpair_sep);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mid_v3_v3v3(vmid, v1_clip, v2_clip);
|
|
|
|
|
}
|
2013-05-31 23:52:39 +00:00
|
|
|
|
|
|
|
|
if (do_global) {
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v1);
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unit->system) {
|
2014-04-17 15:14:07 +10:00
|
|
|
numstr_len = bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3,
|
|
|
|
|
unit->system, B_UNIT_LENGTH, do_split, false);
|
2013-05-31 23:52:39 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
|
2013-05-31 23:52:39 +00:00
|
|
|
}
|
2011-03-27 15:57:27 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
|
2013-05-31 23:52:39 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-29 04:01:52 +00:00
|
|
|
if (me->drawflag & ME_DRAWEXTRA_EDGEANG) {
|
|
|
|
|
const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS);
|
|
|
|
|
BMEdge *eed;
|
|
|
|
|
|
|
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col);
|
|
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
|
2013-03-29 04:38:10 +00:00
|
|
|
BMLoop *l_a, *l_b;
|
|
|
|
|
if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* draw selected edges, or edges next to selected verts while dragging */
|
2013-03-29 04:38:10 +00:00
|
|
|
if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
|
|
|
|
|
(do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
|
|
|
|
|
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
|
2015-03-30 00:51:00 -04:00
|
|
|
/* special case, this is useful to show when verts connected to
|
|
|
|
|
* this edge via a face are being transformed */
|
2013-03-29 04:38:10 +00:00
|
|
|
BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
|
2013-03-29 06:25:22 +00:00
|
|
|
BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
|
|
|
|
|
BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
|
2013-03-29 04:38:10 +00:00
|
|
|
BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)
|
|
|
|
|
)))
|
|
|
|
|
{
|
2013-07-09 12:59:31 +00:00
|
|
|
float v1_clip[3], v2_clip[3];
|
2013-03-29 04:01:52 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(eed->v1), v1);
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(eed->v2), v2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-05-31 23:52:39 +00:00
|
|
|
copy_v3_v3(v1, eed->v1->co);
|
|
|
|
|
copy_v3_v3(v2, eed->v2->co);
|
2013-07-09 12:59:31 +00:00
|
|
|
}
|
2013-03-29 04:01:52 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
copy_v3_v3(v1_clip, v1);
|
|
|
|
|
copy_v3_v3(v2_clip, v2);
|
|
|
|
|
|
|
|
|
|
if (clip_segment_v3_plane_n(v1_clip, v2_clip, clip_planes, 4)) {
|
|
|
|
|
float no_a[3], no_b[3];
|
|
|
|
|
float angle;
|
|
|
|
|
|
2014-01-15 20:03:19 +11:00
|
|
|
if (do_edge_textpair) {
|
|
|
|
|
interp_v3_v3v3(vmid, v2_clip, v1_clip, edge_texpair_sep);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mid_v3_v3v3(vmid, v1_clip, v2_clip);
|
|
|
|
|
}
|
2013-07-09 12:59:31 +00:00
|
|
|
|
|
|
|
|
if (dm) {
|
|
|
|
|
dm->getPolyNo(dm, BM_elem_index_get(l_a->f), no_a);
|
|
|
|
|
dm->getPolyNo(dm, BM_elem_index_get(l_b->f), no_b);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-05-31 23:52:39 +00:00
|
|
|
copy_v3_v3(no_a, l_a->f->no);
|
|
|
|
|
copy_v3_v3(no_b, l_b->f->no);
|
2013-07-09 12:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_global) {
|
2013-05-31 23:52:39 +00:00
|
|
|
mul_mat3_m4_v3(ob->imat, no_a);
|
|
|
|
|
mul_mat3_m4_v3(ob->imat, no_b);
|
2013-07-09 12:59:31 +00:00
|
|
|
normalize_v3(no_a);
|
|
|
|
|
normalize_v3(no_b);
|
2013-05-31 23:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
angle = angle_normalized_v3v3(no_a, no_b);
|
|
|
|
|
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
|
2013-05-31 23:52:39 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
|
2013-05-31 23:52:39 +00:00
|
|
|
}
|
2013-03-29 04:01:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWEXTRA_FACEAREA) {
|
2012-04-23 01:19:50 +00:00
|
|
|
/* would be nice to use BM_face_calc_area, but that is for 2d faces
|
2012-03-08 04:12:11 +00:00
|
|
|
* so instead add up tessellation triangle areas */
|
2015-12-16 01:24:15 -05:00
|
|
|
BMFace *f = NULL;
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2013-01-25 21:21:38 +00:00
|
|
|
#define DRAW_EM_MEASURE_STATS_FACEAREA() \
|
|
|
|
|
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \
|
|
|
|
|
mul_v3_fl(vmid, 1.0f / (float)n); \
|
|
|
|
|
if (unit->system) { \
|
2014-04-17 15:14:07 +10:00
|
|
|
numstr_len = bUnit_AsString( \
|
|
|
|
|
numstr, sizeof(numstr), \
|
|
|
|
|
(double)(area * unit->scale_length * unit->scale_length), \
|
|
|
|
|
3, unit->system, B_UNIT_AREA, do_split, false); \
|
2013-01-25 21:21:38 +00:00
|
|
|
} \
|
|
|
|
|
else { \
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, area); \
|
2013-01-25 21:21:38 +00:00
|
|
|
} \
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col); \
|
2012-05-27 20:13:59 +00:00
|
|
|
} (void)0
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-24 00:55:14 +00:00
|
|
|
area = 0.0;
|
|
|
|
|
zero_v3(vmid);
|
2015-12-16 01:24:15 -05:00
|
|
|
int n = 0;
|
|
|
|
|
for (int i = 0; i < em->tottri; i++) {
|
2011-06-24 00:55:14 +00:00
|
|
|
BMLoop **l = em->looptris[i];
|
2012-02-22 16:52:06 +00:00
|
|
|
if (f && l[0]->f != f) {
|
2011-06-24 00:55:14 +00:00
|
|
|
DRAW_EM_MEASURE_STATS_FACEAREA();
|
|
|
|
|
zero_v3(vmid);
|
|
|
|
|
area = 0.0;
|
|
|
|
|
n = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-24 00:55:14 +00:00
|
|
|
f = l[0]->f;
|
2013-07-09 12:59:31 +00:00
|
|
|
|
|
|
|
|
if (dm) {
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(l[0]->v), v1);
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(l[1]->v), v2);
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(l[2]->v), v3);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(v1, l[0]->v->co);
|
|
|
|
|
copy_v3_v3(v2, l[1]->v->co);
|
|
|
|
|
copy_v3_v3(v3, l[2]->v->co);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-28 09:01:43 +00:00
|
|
|
add_v3_v3(vmid, v1);
|
|
|
|
|
add_v3_v3(vmid, v2);
|
|
|
|
|
add_v3_v3(vmid, v3);
|
|
|
|
|
n += 3;
|
2012-02-22 16:52:06 +00:00
|
|
|
if (do_global) {
|
2010-07-26 18:20:20 +00:00
|
|
|
mul_mat3_m4_v3(ob->obmat, v1);
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v2);
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v3);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2011-06-24 00:55:14 +00:00
|
|
|
area += area_tri_v3(v1, v2, v3);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (f) {
|
2011-06-24 00:55:14 +00:00
|
|
|
DRAW_EM_MEASURE_STATS_FACEAREA();
|
|
|
|
|
}
|
|
|
|
|
#undef DRAW_EM_MEASURE_STATS_FACEAREA
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWEXTRA_FACEANG) {
|
2011-06-24 00:55:14 +00:00
|
|
|
BMFace *efa;
|
2013-03-29 04:01:52 +00:00
|
|
|
const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS);
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
|
|
|
|
|
}
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2012-05-09 16:43:09 +00:00
|
|
|
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
|
2014-01-28 03:52:21 +11:00
|
|
|
const bool is_face_sel = BM_elem_flag_test_bool(efa, BM_ELEM_SELECT);
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2012-05-09 16:43:09 +00:00
|
|
|
if (is_face_sel || do_moving) {
|
|
|
|
|
BMIter liter;
|
|
|
|
|
BMLoop *loop;
|
2013-03-24 12:13:13 +00:00
|
|
|
bool is_first = true;
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2012-05-22 16:09:31 +00:00
|
|
|
BM_ITER_ELEM (loop, &liter, efa, BM_LOOPS_OF_FACE) {
|
2015-07-14 06:30:02 +10:00
|
|
|
if (is_face_sel ||
|
|
|
|
|
(do_moving &&
|
|
|
|
|
(BM_elem_flag_test(loop->v, BM_ELEM_SELECT) ||
|
|
|
|
|
BM_elem_flag_test(loop->prev->v, BM_ELEM_SELECT) ||
|
|
|
|
|
BM_elem_flag_test(loop->next->v, BM_ELEM_SELECT))))
|
|
|
|
|
{
|
2013-07-09 12:59:31 +00:00
|
|
|
float v2_local[3];
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2012-05-09 16:43:09 +00:00
|
|
|
/* lazy init center calc */
|
2012-05-19 20:16:29 +00:00
|
|
|
if (is_first) {
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
BMLoop *l_iter, *l_first;
|
|
|
|
|
float tvec[3];
|
|
|
|
|
zero_v3(vmid);
|
|
|
|
|
l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
|
|
|
|
|
do {
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(l_iter->v), tvec);
|
|
|
|
|
add_v3_v3(vmid, tvec);
|
|
|
|
|
} while ((l_iter = l_iter->next) != l_first);
|
|
|
|
|
mul_v3_fl(vmid, 1.0f / (float)efa->len);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BM_face_calc_center_bounds(efa, vmid);
|
2012-05-19 20:16:29 +00:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
is_first = false;
|
2012-05-09 16:43:09 +00:00
|
|
|
}
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (dm) {
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(loop->prev->v), v1);
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(loop->v), v2);
|
|
|
|
|
dm->getVertCo(dm, BM_elem_index_get(loop->next->v), v3);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_v3_v3(v1, loop->prev->v->co);
|
|
|
|
|
copy_v3_v3(v2, loop->v->co);
|
2012-05-09 16:43:09 +00:00
|
|
|
copy_v3_v3(v3, loop->next->v->co);
|
2013-07-09 12:59:31 +00:00
|
|
|
}
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
copy_v3_v3(v2_local, v2);
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2013-07-09 12:59:31 +00:00
|
|
|
if (do_global) {
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v1);
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v2);
|
|
|
|
|
mul_mat3_m4_v3(ob->obmat, v3);
|
2012-05-09 16:43:09 +00:00
|
|
|
}
|
2011-06-24 00:55:14 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
float angle = angle_v3v3v3(v1, v2, v3);
|
2013-07-09 12:59:31 +00:00
|
|
|
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
|
2013-07-09 12:59:31 +00:00
|
|
|
interp_v3_v3v3(fvec, vmid, v2_local, 0.8f);
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(fvec, numstr, numstr_len, 0, txt_flag, col);
|
2012-05-09 16:43:09 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-26 20:23:13 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2011-08-18 19:07:37 +00:00
|
|
|
|
2011-12-23 08:41:53 +00:00
|
|
|
static void draw_em_indices(BMEditMesh *em)
|
2011-12-22 05:39:23 +00:00
|
|
|
{
|
2012-02-28 13:18:20 +00:00
|
|
|
const short txt_flag = V3D_CACHE_TEXT_ASCII | V3D_CACHE_TEXT_LOCALCLIP;
|
2011-12-23 08:41:53 +00:00
|
|
|
BMEdge *e;
|
|
|
|
|
BMFace *f;
|
|
|
|
|
BMVert *v;
|
2012-01-11 09:33:44 +00:00
|
|
|
char numstr[32];
|
2014-04-17 15:14:07 +10:00
|
|
|
size_t numstr_len;
|
2011-12-22 05:39:23 +00:00
|
|
|
float pos[3];
|
|
|
|
|
unsigned char col[4];
|
|
|
|
|
|
2011-12-23 08:41:53 +00:00
|
|
|
BMIter iter;
|
2012-03-25 23:54:33 +00:00
|
|
|
BMesh *bm = em->bm;
|
2011-12-22 05:39:23 +00:00
|
|
|
|
2011-12-23 08:41:53 +00:00
|
|
|
/* For now, reuse appropriate theme colors from stats text colors */
|
2015-12-16 01:24:15 -05:00
|
|
|
int i = 0;
|
2011-12-27 12:50:23 +00:00
|
|
|
if (em->selectmode & SCE_SELECT_VERTEX) {
|
2011-08-18 19:07:37 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
|
2012-02-12 10:51:45 +00:00
|
|
|
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(v->co, numstr, numstr_len, 0, txt_flag, col);
|
2011-12-27 12:50:23 +00:00
|
|
|
}
|
2011-12-27 13:28:30 +00:00
|
|
|
i++;
|
2011-08-18 19:07:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-27 12:50:23 +00:00
|
|
|
if (em->selectmode & SCE_SELECT_EDGE) {
|
2012-03-25 23:54:33 +00:00
|
|
|
i = 0;
|
2011-12-27 12:50:23 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
|
2012-02-12 10:51:45 +00:00
|
|
|
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
|
2011-12-27 12:50:23 +00:00
|
|
|
mid_v3_v3v3(pos, e->v1->co, e->v2->co);
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
|
2011-12-27 12:50:23 +00:00
|
|
|
}
|
2011-12-27 13:28:30 +00:00
|
|
|
i++;
|
2011-12-22 05:39:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-27 12:50:23 +00:00
|
|
|
if (em->selectmode & SCE_SELECT_FACE) {
|
2012-03-25 23:54:33 +00:00
|
|
|
i = 0;
|
2011-12-27 12:50:23 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
|
2012-02-12 10:51:45 +00:00
|
|
|
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
|
2012-04-23 01:19:50 +00:00
|
|
|
BM_face_calc_center_mean(f, pos);
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
|
2011-12-27 12:50:23 +00:00
|
|
|
}
|
2011-12-27 13:28:30 +00:00
|
|
|
i++;
|
2011-12-22 05:39:23 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-07-14 23:41:33 +00:00
|
|
|
BMEditMesh *em = userData;
|
|
|
|
|
|
|
|
|
|
if (UNLIKELY(index >= em->bm->totface))
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
BMFace *efa = BM_face_at_index(em->bm, index);
|
2013-06-20 07:00:57 +00:00
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-07-14 23:41:33 +00:00
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2013-07-14 23:41:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-07-14 23:41:33 +00:00
|
|
|
BMEditMesh *em = userData;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-07-14 23:41:33 +00:00
|
|
|
if (UNLIKELY(index >= em->bm->totface))
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2013-07-14 23:41:33 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
BMFace *efa = BM_face_at_index(em->bm, index);
|
2013-07-14 23:41:33 +00:00
|
|
|
|
|
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
|
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-31 23:52:39 +00:00
|
|
|
static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
|
2013-01-18 19:01:26 +00:00
|
|
|
Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-05-31 23:52:39 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
2008-12-19 12:14:58 +00:00
|
|
|
Mesh *me = ob->data;
|
2013-06-24 04:51:56 +00:00
|
|
|
BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true); /* annoying but active faces is stored differently */
|
2009-05-16 16:18:08 +00:00
|
|
|
BMEdge *eed_act = NULL;
|
|
|
|
|
BMVert *eve_act = NULL;
|
2013-07-20 03:51:49 +00:00
|
|
|
bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-07-17 10:54:00 +00:00
|
|
|
if (em->bm->selected.last) {
|
2012-03-25 23:54:33 +00:00
|
|
|
BMEditSelection *ese = em->bm->selected.last;
|
2015-03-30 00:51:00 -04:00
|
|
|
/* face is handled above */
|
2012-03-03 16:31:46 +00:00
|
|
|
#if 0
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ese->type == BM_FACE) {
|
2011-09-13 13:41:20 +00:00
|
|
|
efa_act = (BMFace *)ese->data;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-10-11 03:25:19 +00:00
|
|
|
else
|
2012-03-03 16:31:46 +00:00
|
|
|
#endif
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ese->htype == BM_EDGE) {
|
2012-02-25 22:23:40 +00:00
|
|
|
eed_act = (BMEdge *)ese->ele;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ese->htype == BM_VERT) {
|
2012-02-25 22:23:40 +00:00
|
|
|
eve_act = (BMVert *)ese->ele;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-07-01 00:42:44 +00:00
|
|
|
if (check_object_draw_editweight(me, finalDM)) {
|
|
|
|
|
if (dt > OB_WIRE) {
|
2013-07-01 01:25:21 +00:00
|
|
|
draw_mesh_paint_weight_faces(finalDM, true, draw_em_fancy__setFaceOpts, me->edit_btmesh);
|
2013-07-01 00:42:44 +00:00
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 1.0);
|
2013-07-01 00:42:44 +00:00
|
|
|
glDepthMask(0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
2013-07-01 01:25:21 +00:00
|
|
|
draw_mesh_paint_weight_faces(finalDM, false, draw_em_fancy__setFaceOpts, me->edit_btmesh);
|
2014-03-20 11:49:01 +11:00
|
|
|
draw_mesh_paint_weight_edges(rv3d, finalDM, true, true, draw_dm_edges__setDrawOptions, me->edit_btmesh->bm);
|
2013-07-01 00:42:44 +00:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (dt > OB_WIRE) {
|
2013-07-20 03:51:49 +00:00
|
|
|
if (use_occlude_wire) {
|
2013-07-22 21:45:01 +00:00
|
|
|
/* use the cageDM since it always overlaps the editmesh faces */
|
2013-07-20 03:51:49 +00:00
|
|
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
2013-07-22 21:45:01 +00:00
|
|
|
cageDM->drawMappedFaces(cageDM, draw_em_fancy__setFaceOpts,
|
2015-11-27 21:16:26 +01:00
|
|
|
GPU_object_material_bind, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN | DM_DRAW_NEED_NORMALS);
|
2015-12-22 20:55:18 +01:00
|
|
|
GPU_object_material_unbind();
|
2013-07-20 03:51:49 +00:00
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
|
}
|
|
|
|
|
else if (check_object_draw_texture(scene, v3d, dt)) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw_glsl_material(scene, ob, v3d, dt)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
2011-12-04 23:04:43 +00:00
|
|
|
|
2015-11-23 21:42:17 +01:00
|
|
|
finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind,
|
2011-12-04 23:04:43 +00:00
|
|
|
draw_em_fancy__setGLSLFaceOpts, em);
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_unbind();
|
2011-12-04 23:04:43 +00:00
|
|
|
|
2011-11-21 11:46:05 +00:00
|
|
|
glFrontFace(GL_CCW);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
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_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
2015-11-27 21:16:26 +01:00
|
|
|
finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, GPU_object_material_bind, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN | DM_DRAW_NEED_NORMALS);
|
2011-12-04 23:04:43 +00:00
|
|
|
|
2011-11-21 11:46:05 +00:00
|
|
|
glFrontFace(GL_CCW);
|
2015-11-27 21:32:14 +01:00
|
|
|
|
|
|
|
|
GPU_object_material_unbind();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* Setup for drawing wire over, disable zbuffer
|
|
|
|
|
* write to show selected edge wires better */
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_ThemeColor(TH_WIRE_EDIT);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glDepthMask(0);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (cageDM != finalDM) {
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_ThemeColorBlend(TH_WIRE_EDIT, TH_BACK, 0.7);
|
2010-03-22 11:59:36 +00:00
|
|
|
finalDM->drawEdges(finalDM, 1, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-07-20 03:51:49 +00:00
|
|
|
|
|
|
|
|
if ((me->drawflag & ME_DRAWFACES) && (use_occlude_wire == false)) { /* transp faces */
|
2012-12-20 07:57:26 +00:00
|
|
|
unsigned char col1[4], col2[4], col3[4];
|
|
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
|
unsigned char col4[4];
|
|
|
|
|
#endif
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_FACE, col1);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
|
2012-12-20 07:57:26 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
|
|
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
|
UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col4);
|
|
|
|
|
#endif
|
2012-07-08 20:36:00 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
2012-07-08 20:36:00 +00:00
|
|
|
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
|
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* don't draw unselected faces, only selected, this is MUCH nicer when texturing */
|
2012-04-03 14:08:04 +00:00
|
|
|
if (check_object_draw_texture(scene, v3d, dt))
|
2008-12-19 12:14:58 +00:00
|
|
|
col1[3] = 0;
|
2012-07-08 20:36:00 +00:00
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-03-13 06:44:43 +00:00
|
|
|
if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE) || !CustomData_has_layer(&em->bm->pdata, CD_FREESTYLE_FACE))
|
2012-12-20 07:57:26 +00:00
|
|
|
col4[3] = 0;
|
2011-10-06 02:04:43 +00:00
|
|
|
|
2012-02-21 01:40:04 +00:00
|
|
|
draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
|
2012-12-20 07:57:26 +00:00
|
|
|
#else
|
|
|
|
|
draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
2012-07-08 20:36:00 +00:00
|
|
|
glDepthMask(1); /* restore write in zbuffer */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (efa_act) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* even if draw faces is off it would be nice to draw the stipple face
|
2015-03-30 00:51:00 -04:00
|
|
|
* Make all other faces zero alpha except for the active */
|
|
|
|
|
unsigned char col1[4], col2[4], col3[4];
|
|
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
|
unsigned char col4[4];
|
|
|
|
|
col4[3] = 0; /* don't draw */
|
|
|
|
|
#endif
|
|
|
|
|
col1[3] = col2[3] = 0; /* don't draw */
|
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
|
2012-07-08 20:36:00 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnable(GL_BLEND);
|
2012-07-08 20:36:00 +00:00
|
|
|
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
|
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2012-02-21 01:40:04 +00:00
|
|
|
draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
|
2012-12-20 07:57:26 +00:00
|
|
|
#else
|
|
|
|
|
draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
2012-07-08 20:36:00 +00:00
|
|
|
glDepthMask(1); /* restore write in zbuffer */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* here starts all fancy draw-extra over */
|
2012-04-03 14:08:04 +00:00
|
|
|
if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) {
|
2012-03-18 07:38:51 +00:00
|
|
|
/* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* only draw selected edges otherwise there is no way of telling if a face is selected */
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 1, eed_act);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (me->drawflag & ME_DRAWSEAMS) {
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColor(TH_EDGE_SEAM);
|
|
|
|
|
glLineWidth(2);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_edges_seams(em, cageDM);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ub(0, 0, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glLineWidth(1);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWSHARP) {
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColor(TH_EDGE_SHARP);
|
|
|
|
|
glLineWidth(2);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_edges_sharp(em, cageDM);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ub(0, 0, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
glLineWidth(1);
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-03-13 06:44:43 +00:00
|
|
|
if (me->drawflag & ME_DRAW_FREESTYLE_EDGE && CustomData_has_layer(&em->bm->edata, CD_FREESTYLE_EDGE)) {
|
2011-10-06 02:04:43 +00:00
|
|
|
UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
|
|
|
|
|
glLineWidth(2);
|
|
|
|
|
|
2012-02-21 01:40:04 +00:00
|
|
|
draw_dm_edges_freestyle(em, cageDM);
|
2011-10-06 02:04:43 +00:00
|
|
|
|
2013-04-05 16:55:12 +00:00
|
|
|
glColor3ub(0, 0, 0);
|
2011-10-06 02:04:43 +00:00
|
|
|
glLineWidth(1);
|
|
|
|
|
}
|
2012-12-20 07:57:26 +00:00
|
|
|
#endif
|
2011-10-06 02:04:43 +00:00
|
|
|
|
2013-06-20 11:18:19 +00:00
|
|
|
if (me->drawflag & ME_DRAWCREASES) {
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_creases(em, cageDM);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWBWEIGHTS) {
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_dm_bweights(em, scene, cageDM);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2011-12-04 23:04:43 +00:00
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-09-15 06:29:32 +00:00
|
|
|
|
|
|
|
|
{
|
2012-05-22 15:29:27 +00:00
|
|
|
draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAWNORMALS) {
|
2008-12-19 12:14:58 +00:00
|
|
|
UI_ThemeColor(TH_NORMAL);
|
2012-05-01 11:01:24 +00:00
|
|
|
draw_dm_face_normals(em, scene, ob, cageDM);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (me->drawflag & ME_DRAW_VNORMALS) {
|
2010-02-11 03:37:51 +00:00
|
|
|
UI_ThemeColor(TH_VNORMAL);
|
2012-05-01 11:01:24 +00:00
|
|
|
draw_dm_vert_normals(em, scene, ob, cageDM);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-04-13 12:18:51 +02:00
|
|
|
if (me->drawflag & ME_DRAW_LNORMALS) {
|
2014-08-25 12:45:49 +02:00
|
|
|
UI_ThemeColor(TH_LNORMAL);
|
2014-04-13 12:18:51 +02:00
|
|
|
draw_dm_loop_normals(em, scene, ob, cageDM);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-03-29 04:01:52 +00:00
|
|
|
if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
|
|
|
|
|
ME_DRAWEXTRA_FACEAREA |
|
|
|
|
|
ME_DRAWEXTRA_FACEANG |
|
|
|
|
|
ME_DRAWEXTRA_EDGEANG)) &&
|
2012-09-09 00:00:21 +00:00
|
|
|
!(v3d->flag2 & V3D_RENDER_OVERRIDE))
|
2011-12-03 20:49:41 +00:00
|
|
|
{
|
2013-05-31 23:52:39 +00:00
|
|
|
draw_em_measure_stats(ar, v3d, ob, em, &scene->unit);
|
2011-12-03 20:49:41 +00:00
|
|
|
}
|
2011-12-22 05:39:23 +00:00
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
if ((G.debug & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) &&
|
2012-05-20 19:49:27 +00:00
|
|
|
!(v3d->flag2 & V3D_RENDER_OVERRIDE))
|
|
|
|
|
{
|
2011-12-22 05:39:23 +00:00
|
|
|
draw_em_indices(em);
|
2011-12-03 20:49:41 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt > OB_WIRE) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glDepthMask(1);
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_unbind();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-07-20 03:51:49 +00:00
|
|
|
#if 0 /* currently not needed */
|
|
|
|
|
else if (use_occlude_wire) {
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
2013-07-20 03:51:49 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mesh drawing routines */
|
|
|
|
|
|
|
|
|
|
static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
|
|
|
|
|
{
|
2013-03-24 12:13:13 +00:00
|
|
|
if ((v3d->transp == false) && /* not when we draw the transparent pass */
|
|
|
|
|
(ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */
|
2012-03-09 22:00:40 +00:00
|
|
|
{
|
2011-03-27 15:57:27 +00:00
|
|
|
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
|
2008-12-19 12:14:58 +00:00
|
|
|
glDepthMask(0);
|
2012-10-11 03:25:19 +00:00
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
/* if transparent, we cannot draw the edges for solid select... edges
|
|
|
|
|
* have no material info. GPU_object_material_visible will skip the
|
|
|
|
|
* transparent faces */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->dtx & OB_DRAWTRANSP) {
|
2012-03-18 06:01:33 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
2015-11-27 21:32:14 +01:00
|
|
|
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_visible);
|
2008-12-19 12:14:58 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2010-03-22 11:59:36 +00:00
|
|
|
dm->drawEdges(dm, 0, 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glLineWidth(1.0);
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-14 22:26:20 +11:00
|
|
|
static bool object_is_halo(Scene *scene, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
const Material *ma = give_current_material(ob, 1);
|
|
|
|
|
return (ma && (ma->material_type == MA_TYPE_HALO) && !BKE_scene_use_new_shading_nodes(scene));
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 10:15:49 +00:00
|
|
|
static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
|
2013-01-18 19:01:26 +00:00
|
|
|
const char dt, const unsigned char ob_wire_col[4], const short dflag)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-04-09 11:48:04 +10:00
|
|
|
#ifdef WITH_GAMEENGINE
|
|
|
|
|
Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, scene) : base->object;
|
|
|
|
|
#else
|
|
|
|
|
Object *ob = base->object;
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
Mesh *me = ob->data;
|
2012-03-25 23:54:33 +00:00
|
|
|
eWireDrawMode draw_wire = OBDRAW_WIRE_OFF;
|
2015-04-16 04:14:01 +10:00
|
|
|
bool /* no_verts,*/ no_edges, no_faces;
|
2012-03-25 23:54:33 +00:00
|
|
|
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
|
2013-03-29 04:01:52 +00:00
|
|
|
const bool is_obact = (ob == OBACT);
|
2014-02-26 16:00:54 +11:00
|
|
|
int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!dm)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
2011-06-16 10:41:00 +00:00
|
|
|
|
2014-04-09 04:03:25 +03:00
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
|
Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview.
User side:
* Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though.
* Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one.
* Last active preview modifier in stack wins!
Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now.
Dev side:
* In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW
* Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope).
* Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data.
* Added three new modifier funcs, to handle preview modifiers in draw code / mod stack.
* For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s).
So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work.
2012-01-22 17:54:23 +00:00
|
|
|
/* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
|
|
|
|
|
* Note: Last "preview-active" modifier in stack will win! */
|
2015-07-25 16:16:25 +02:00
|
|
|
if (DM_get_loop_data_layer(dm, CD_PREVIEW_MLOOPCOL) && modifiers_isPreview(ob))
|
Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview.
User side:
* Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though.
* Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one.
* Last active preview modifier in stack wins!
Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now.
Dev side:
* In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW
* Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope).
* Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data.
* Added three new modifier funcs, to handle preview modifiers in draw code / mod stack.
* For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s).
So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work.
2012-01-22 17:54:23 +00:00
|
|
|
draw_flags |= DRAW_MODIFIERS_PREVIEW;
|
2011-11-26 13:11:55 +00:00
|
|
|
|
|
|
|
|
/* Unwanted combination */
|
|
|
|
|
if (draw_flags & DRAW_FACE_SELECT) {
|
2012-03-25 23:54:33 +00:00
|
|
|
draw_wire = OBDRAW_WIRE_OFF;
|
2011-11-26 13:11:55 +00:00
|
|
|
}
|
|
|
|
|
else if (ob->dtx & OB_DRAWWIRE) {
|
2012-03-25 23:54:33 +00:00
|
|
|
draw_wire = OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-16 04:14:01 +10:00
|
|
|
/* check polys instead of tessfaces because of dyntopo where tessfaces don't exist */
|
2015-08-05 15:11:50 +02:00
|
|
|
if (dm->type == DM_TYPE_CCGDM) {
|
|
|
|
|
no_edges = !subsurf_has_edges(dm);
|
|
|
|
|
no_faces = !subsurf_has_faces(dm);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
no_edges = (dm->getNumEdges(dm) == 0);
|
|
|
|
|
no_faces = (dm->getNumPolys(dm) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* vertexpaint, faceselect wants this, but it doesnt work for shaded? */
|
2012-03-25 23:54:33 +00:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt == OB_BOUNDBOX) {
|
|
|
|
|
if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0)
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2015-04-16 04:14:01 +10:00
|
|
|
else if ((no_faces && no_edges) ||
|
2015-02-14 22:26:20 +11:00
|
|
|
((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
|
|
|
|
|
{
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(1.5);
|
|
|
|
|
dm->drawVerts(dm);
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
2015-04-16 04:14:01 +10:00
|
|
|
else if ((dt == OB_WIRE) || no_faces) {
|
2015-03-30 00:51:00 -04:00
|
|
|
draw_wire = OBDRAW_WIRE_ON; /* draw wire only, no depth buffer stuff */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-09-09 00:00:21 +00:00
|
|
|
else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
|
|
|
|
|
check_object_draw_texture(scene, v3d, dt))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-03-29 11:40:26 +02:00
|
|
|
bool draw_loose = true;
|
|
|
|
|
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((v3d->flag & V3D_SELECT_OUTLINE) &&
|
|
|
|
|
((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
|
|
|
|
|
(base->flag & SELECT) &&
|
|
|
|
|
!(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
|
|
|
|
|
(draw_wire == OBDRAW_WIRE_OFF))
|
2011-11-26 13:11:55 +00:00
|
|
|
{
|
2008-12-19 12:14:58 +00:00
|
|
|
draw_mesh_object_outline(v3d, ob, dm);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) {
|
2014-03-29 11:40:26 +02:00
|
|
|
Paint *p;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
2014-03-29 11:40:26 +02:00
|
|
|
|
|
|
|
|
if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene))) {
|
|
|
|
|
GPUVertexAttribs gattribs;
|
|
|
|
|
float planes[4][4];
|
|
|
|
|
float (*fpl)[4] = NULL;
|
2014-04-17 19:33:54 +10:00
|
|
|
const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
|
2014-03-29 11:40:26 +02:00
|
|
|
|
|
|
|
|
if (ob->sculpt->partial_redraw) {
|
|
|
|
|
if (ar->do_draw & RGN_DRAW_PARTIAL) {
|
2014-06-23 21:59:34 +10:00
|
|
|
ED_sculpt_redraw_planes_get(planes, ar, rv3d, ob);
|
2014-03-29 11:40:26 +02:00
|
|
|
fpl = planes;
|
|
|
|
|
ob->sculpt->partial_redraw = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_bind(1, &gattribs);
|
2014-03-29 11:40:26 +02:00
|
|
|
dm->drawFacesSolid(dm, fpl, fast, NULL);
|
|
|
|
|
draw_loose = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesGLSL(dm, GPU_object_material_bind);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
#if 0 /* XXX */
|
|
|
|
|
if (BKE_bproperty_object_get(ob, "Text"))
|
|
|
|
|
draw_mesh_text(ob, 1);
|
|
|
|
|
#endif
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_unbind();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glFrontFace(GL_CCW);
|
2013-04-18 10:39:53 +00:00
|
|
|
|
|
|
|
|
if (draw_flags & DRAW_FACE_SELECT)
|
2014-12-02 17:56:40 +01:00
|
|
|
draw_mesh_face_select(rv3d, me, dm, false);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-06-17 18:04:56 +00:00
|
|
|
draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 11:40:26 +02:00
|
|
|
if (draw_loose && !(draw_flags & DRAW_FACE_SELECT)) {
|
2012-08-16 16:32:50 +00:00
|
|
|
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2010-05-23 10:48:35 +00:00
|
|
|
dm->drawLooseEdges(dm);
|
2012-08-16 16:32:50 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (dt == OB_SOLID) {
|
2012-05-10 06:32:24 +00:00
|
|
|
if (draw_flags & DRAW_MODIFIERS_PREVIEW) {
|
2011-06-16 10:41:00 +00:00
|
|
|
/* for object selection draws no shade */
|
2012-06-10 10:15:49 +00:00
|
|
|
if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
|
2015-11-27 21:32:14 +01:00
|
|
|
GPU_object_material_unbind();
|
2011-06-16 10:41:00 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-11-27 21:32:14 +01:00
|
|
|
const float specular[3] = {0.47f, 0.47f, 0.47f};
|
2012-06-07 09:04:45 +00:00
|
|
|
|
2011-06-16 10:41:00 +00:00
|
|
|
/* draw outline */
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((v3d->flag & V3D_SELECT_OUTLINE) &&
|
|
|
|
|
((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
|
|
|
|
|
(base->flag & SELECT) &&
|
|
|
|
|
(draw_wire == OBDRAW_WIRE_OFF) &&
|
|
|
|
|
(ob->sculpt == NULL))
|
2011-11-26 13:11:55 +00:00
|
|
|
{
|
2011-06-16 10:41:00 +00:00
|
|
|
draw_mesh_object_outline(v3d, ob, dm);
|
2011-11-26 13:11:55 +00:00
|
|
|
}
|
2011-06-16 10:41:00 +00:00
|
|
|
|
|
|
|
|
/* materials arent compatible with vertex colors */
|
|
|
|
|
GPU_end_object_materials();
|
|
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
/* set default specular */
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_colors(NULL, specular, 35, 1.0f);
|
|
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
|
2011-06-16 10:41:00 +00:00
|
|
|
|
2015-11-27 21:16:26 +01:00
|
|
|
dm->drawMappedFaces(dm, NULL, NULL, NULL, NULL, DM_DRAW_USE_COLORS | DM_DRAW_NEED_NORMALS);
|
2011-06-16 10:41:00 +00:00
|
|
|
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
|
2011-06-16 10:41:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-01-14 12:51:17 +00:00
|
|
|
else {
|
|
|
|
|
Paint *p;
|
2009-10-27 19:53:34 +00:00
|
|
|
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((v3d->flag & V3D_SELECT_OUTLINE) &&
|
|
|
|
|
((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
|
|
|
|
|
(base->flag & SELECT) &&
|
|
|
|
|
(draw_wire == OBDRAW_WIRE_OFF) &&
|
|
|
|
|
(ob->sculpt == NULL))
|
2011-11-26 13:11:55 +00:00
|
|
|
{
|
2010-01-14 12:51:17 +00:00
|
|
|
draw_mesh_object_outline(v3d, ob, dm);
|
2011-11-26 13:11:55 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
2010-01-14 12:51:17 +00:00
|
|
|
|
Paint refactoring commit, non-disruptive (in theory :p)
* Fix precision overflow issue with overlay previews,
* Expose alpha mask mapping to UI (still not functional but coming soon).
* More overlay refactoring:
Overlay now does minimal checking for texture refresh.
Instead, we now have invalidation flags to set an aspect of the brush
overlay as invalid. This is necessary because this way we will be able to
separate and preview different brush attributes on the overlays, using
different textures:
These attributes/aspects are:
Primary texture (main texture for sculpt, vertex, imapaint)
Secondary texture (mask/alpha texture for imapaint)
Cursor texture (cursor texture. It involves brush strength and curves)
Modified the relevant RNA property update functions and C update callback
functions to call the relevant cursor invalidation functions instead
of checking every frame for multiple properties.
Properties that affect this are:
Image changes, if image is used by current brush,
Texture slot changes, similarly
Curve changes,
Object mode change invalidates the cursor
Paint tool change invalidates the cursor.
These changes give slightly more invalidation cases than simply
comparing the relevant properties each frame, but these do not occur in
performance critical moments and it's a much more elegant system than
adding more variables to check per frame each time we add something on
the system.
2013-04-12 17:21:31 +00:00
|
|
|
if (ob->sculpt && (p = BKE_paint_get_active(scene))) {
|
2010-01-14 12:51:17 +00:00
|
|
|
float planes[4][4];
|
|
|
|
|
float (*fpl)[4] = NULL;
|
2014-04-17 19:33:54 +10:00
|
|
|
const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
|
2010-01-14 12:51:17 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->sculpt->partial_redraw) {
|
|
|
|
|
if (ar->do_draw & RGN_DRAW_PARTIAL) {
|
2014-06-23 21:59:34 +10:00
|
|
|
ED_sculpt_redraw_planes_get(planes, ar, rv3d, ob);
|
2010-03-22 11:59:36 +00:00
|
|
|
fpl = planes;
|
|
|
|
|
ob->sculpt->partial_redraw = 0;
|
|
|
|
|
}
|
2010-01-14 12:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesSolid(dm, fpl, fast, GPU_object_material_bind);
|
2010-01-14 12:51:17 +00:00
|
|
|
}
|
|
|
|
|
else
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
|
2010-01-14 12:51:17 +00:00
|
|
|
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
GPU_object_material_unbind();
|
2012-02-25 18:09:39 +00:00
|
|
|
|
2012-08-16 16:32:50 +00:00
|
|
|
if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2010-01-14 12:51:17 +00:00
|
|
|
dm->drawLooseEdges(dm);
|
2012-08-16 16:32:50 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (dt == OB_PAINT) {
|
2012-05-10 06:32:24 +00:00
|
|
|
draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
|
|
|
|
|
|
|
|
|
|
/* since we already draw wire as wp guide, don't draw over the top */
|
|
|
|
|
draw_wire = OBDRAW_WIRE_OFF;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2010-01-11 18:10:13 +00:00
|
|
|
|
2012-08-16 17:23:47 +00:00
|
|
|
if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */
|
2015-03-30 00:51:00 -04:00
|
|
|
/* when overriding with render only, don't bother */
|
2012-08-16 17:23:47 +00:00
|
|
|
(((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0))
|
|
|
|
|
{
|
2012-03-08 04:12:11 +00:00
|
|
|
/* When using wireframe object draw in particle edit mode
|
2010-01-11 18:10:13 +00:00
|
|
|
* the mesh gets in the way of seeing the particles, fade the wire color
|
|
|
|
|
* with the background. */
|
|
|
|
|
|
2012-08-16 17:23:47 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
|
2012-08-16 18:37:30 +00:00
|
|
|
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f);
|
2012-08-16 17:23:47 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2010-01-11 18:10:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If drawing wire and drawtype is not OB_WIRE then we are
|
|
|
|
|
* overlaying the wires.
|
|
|
|
|
*
|
|
|
|
|
* UPDATE bug #10290 - With this wire-only objects can draw
|
|
|
|
|
* behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059
|
|
|
|
|
*
|
|
|
|
|
* if draw wire is 1 then just drawing wire, no need for depth buffer stuff,
|
|
|
|
|
* otherwise this wire is to overlay solid mode faces so do some depth buffer tricks.
|
|
|
|
|
*/
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 1.0);
|
2012-07-08 20:36:00 +00:00
|
|
|
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-16 04:14:01 +10:00
|
|
|
dm->drawEdges(dm, ((dt == OB_WIRE) || no_faces), (ob->dtx & OB_DRAW_ALL_EDGES) != 0);
|
2010-05-20 09:17:49 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glDepthMask(1);
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-09-18 17:10:28 +00:00
|
|
|
|
2014-02-26 16:00:54 +11:00
|
|
|
if (is_obact && BKE_paint_select_vert_test(ob)) {
|
2015-04-20 23:37:04 +10:00
|
|
|
const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0;
|
2011-07-18 16:47:21 +00:00
|
|
|
glColor3f(0.0f, 0.0f, 0.0f);
|
2011-08-09 16:32:15 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
2012-12-23 01:54:11 +00:00
|
|
|
|
|
|
|
|
if (!use_depth) glDisable(GL_DEPTH_TEST);
|
2013-12-09 20:59:29 +11:00
|
|
|
else ED_view3d_polygon_offset(rv3d, 1.0);
|
2011-09-18 01:09:18 +00:00
|
|
|
drawSelectedVertices(dm, ob->data);
|
2012-12-23 01:54:11 +00:00
|
|
|
if (!use_depth) glEnable(GL_DEPTH_TEST);
|
2013-12-09 20:59:29 +11:00
|
|
|
else ED_view3d_polygon_offset(rv3d, 0.0);
|
2011-09-18 01:09:18 +00:00
|
|
|
|
2011-07-18 16:47:21 +00:00
|
|
|
glPointSize(1.0f);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
dm->release(dm);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* returns true if nothing was drawn, for detecting to draw an object center */
|
2013-03-24 12:13:13 +00:00
|
|
|
static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|
|
|
|
const char dt, const unsigned char ob_wire_col[4], const short dflag)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
|
|
|
|
Object *obedit = scene->obedit;
|
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
BMEditMesh *em = me->edit_btmesh;
|
2013-03-24 12:13:13 +00:00
|
|
|
bool do_alpha_after = false, drawlinked = false, retval = false;
|
2011-08-24 20:28:54 +00:00
|
|
|
|
2011-08-25 15:49:52 +00:00
|
|
|
/* If we are drawing shadows and any of the materials don't cast a shadow,
|
|
|
|
|
* then don't draw the object */
|
|
|
|
|
if (v3d->flag2 & V3D_RENDER_SHADOW) {
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < ob->totcol; ++i) {
|
2012-03-25 23:54:33 +00:00
|
|
|
Material *ma = give_current_material(ob, i);
|
2014-04-23 15:02:06 +09:00
|
|
|
if (ma && !(ma->mode2 & MA_CASTSHADOW)) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2011-08-25 15:49:52 +00:00
|
|
|
}
|
2011-08-24 20:28:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (obedit && ob != obedit && ob->data == obedit->data) {
|
2012-09-23 18:50:56 +00:00
|
|
|
if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {}
|
2012-03-10 22:00:55 +00:00
|
|
|
else if (ob->modifiers.first || obedit->modifiers.first) {}
|
2013-03-24 12:13:13 +00:00
|
|
|
else drawlinked = true;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-05-25 09:26:47 +00:00
|
|
|
|
|
|
|
|
/* backface culling */
|
|
|
|
|
if (v3d->flag2 & V3D_BACKFACE_CULLING) {
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob == obedit || drawlinked) {
|
2008-12-19 12:14:58 +00:00
|
|
|
DerivedMesh *finalDM, *cageDM;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (obedit != ob)
|
2009-05-16 16:18:08 +00:00
|
|
|
finalDM = cageDM = editbmesh_get_derived_base(ob, em);
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2015-07-02 16:20:22 +10:00
|
|
|
cageDM = editbmesh_get_derived_cage_and_final(
|
|
|
|
|
scene, ob, em, scene->customdata_mask,
|
|
|
|
|
&finalDM);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-04-09 04:03:25 +03:00
|
|
|
DM_update_materials(finalDM, ob);
|
2015-05-19 17:58:24 +10:00
|
|
|
if (cageDM != finalDM) {
|
|
|
|
|
DM_update_materials(cageDM, ob);
|
|
|
|
|
}
|
2014-04-09 04:03:25 +03:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt > OB_WIRE) {
|
2013-03-24 12:13:13 +00:00
|
|
|
const bool glsl = draw_glsl_material(scene, ob, v3d, dt);
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
2011-11-26 13:11:55 +00:00
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-31 23:52:39 +00:00
|
|
|
draw_em_fancy(scene, ar, v3d, ob, em, cageDM, finalDM, dt);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_end_object_materials();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (obedit != ob && finalDM)
|
2008-12-19 12:14:58 +00:00
|
|
|
finalDM->release(finalDM);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-05-08 23:39:31 +00:00
|
|
|
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
|
2014-03-20 12:17:44 +11:00
|
|
|
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
|
2014-06-16 17:12:08 +10:00
|
|
|
if (dt > OB_WIRE) {
|
|
|
|
|
const bool glsl = draw_glsl_material(scene, ob, v3d, dt);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-06-16 17:12:08 +10:00
|
|
|
if (dt == OB_SOLID || glsl) {
|
|
|
|
|
const bool check_alpha = check_alpha_pass(base);
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl,
|
|
|
|
|
(check_alpha) ? &do_alpha_after : NULL);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-16 16:32:50 +00:00
|
|
|
draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
|
2009-07-13 00:40:20 +00:00
|
|
|
|
|
|
|
|
GPU_end_object_materials();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (me->totvert == 0) retval = true;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-05 12:18:04 +00:00
|
|
|
if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
|
2012-05-16 08:42:50 +00:00
|
|
|
/* GPU_begin_object_materials checked if this is needed */
|
|
|
|
|
if (do_alpha_after) {
|
|
|
|
|
if (ob->dtx & OB_DRAWXRAY) {
|
2012-06-10 10:15:49 +00:00
|
|
|
ED_view3d_after_add(&v3d->afterdraw_xraytransp, base, dflag);
|
2012-05-16 08:42:50 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-06-10 10:15:49 +00:00
|
|
|
ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
|
2012-05-16 08:42:50 +00:00
|
|
|
}
|
2010-08-25 14:23:02 +00:00
|
|
|
}
|
2012-05-16 08:42:50 +00:00
|
|
|
else if (ob->dtx & OB_DRAWXRAY && ob->dtx & OB_DRAWTRANSP) {
|
|
|
|
|
/* special case xray+transp when alpha is 1.0, without this the object vanishes */
|
|
|
|
|
if (v3d->xray == 0 && v3d->transp == 0) {
|
2012-06-10 10:15:49 +00:00
|
|
|
ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
|
2012-05-16 08:42:50 +00:00
|
|
|
}
|
2010-08-25 14:23:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-05-25 09:26:47 +00:00
|
|
|
|
|
|
|
|
if (v3d->flag2 & V3D_BACKFACE_CULLING)
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************** DRAW DISPLIST ****************** */
|
|
|
|
|
|
|
|
|
|
|
2014-06-04 08:36:22 +10:00
|
|
|
/**
|
|
|
|
|
* \param dl_type_mask Only draw types matching this mask.
|
|
|
|
|
* \return true when nothing was drawn
|
|
|
|
|
*/
|
|
|
|
|
static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2015-12-16 01:24:15 -05:00
|
|
|
if (dlbase == NULL) return true;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-12-09 14:37:26 +00:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2012-03-18 06:01:33 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (DispList *dl = dlbase->first; dl; dl = dl->next) {
|
2014-06-04 08:36:22 +10:00
|
|
|
if (dl->parts == 0 || dl->nr == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((dl_type_mask & (1 << dl->type)) == 0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
continue;
|
2014-06-04 08:36:22 +10:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
const float *data = dl->verts;
|
|
|
|
|
int parts;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (dl->type) {
|
2012-03-18 06:01:33 +00:00
|
|
|
case DL_SEGM:
|
|
|
|
|
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, data);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (parts = 0; parts < dl->parts; parts++)
|
|
|
|
|
glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
|
|
|
|
case DL_POLY:
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, 0, data);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (parts = 0; parts < dl->parts; parts++)
|
|
|
|
|
glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case DL_SURF:
|
|
|
|
|
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, data);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (parts = 0; parts < dl->parts; parts++) {
|
2012-03-18 06:01:33 +00:00
|
|
|
if (dl->flag & DL_CYCL_U)
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr);
|
2012-03-18 06:01:33 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int nr = 0; nr < dl->nr; nr++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
int ofs = 3 * dl->nr;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
data = (dl->verts) + 3 * nr;
|
|
|
|
|
parts = dl->parts;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
if (dl->flag & DL_CYCL_V) glBegin(GL_LINE_LOOP);
|
|
|
|
|
else glBegin(GL_LINE_STRIP);
|
|
|
|
|
|
|
|
|
|
while (parts--) {
|
|
|
|
|
glVertex3fv(data);
|
2012-03-25 23:54:33 +00:00
|
|
|
data += ofs;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2012-09-03 02:41:12 +00:00
|
|
|
#if 0
|
|
|
|
|
/* (ton) this code crashes for me when resolv is 86 or higher... no clue */
|
2013-01-08 02:06:16 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, sizeof(float) * 3 * dl->nr, data + 3 * nr);
|
2012-09-03 02:41:12 +00:00
|
|
|
if (dl->flag & DL_CYCL_V)
|
|
|
|
|
glDrawArrays(GL_LINE_LOOP, 0, dl->parts);
|
|
|
|
|
else
|
|
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, dl->parts);
|
|
|
|
|
#endif
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DL_INDEX3:
|
2014-06-04 08:36:22 +10:00
|
|
|
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
|
|
|
|
glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index);
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DL_INDEX4:
|
2014-06-04 08:36:22 +10:00
|
|
|
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
|
|
|
|
glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index);
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-09 14:37:26 +00:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2012-03-18 06:01:33 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-04 08:36:22 +10:00
|
|
|
static bool drawDispListwire(ListBase *dlbase, const short ob_type)
|
|
|
|
|
{
|
|
|
|
|
unsigned int dl_mask = 0xffffffff;
|
|
|
|
|
|
|
|
|
|
/* skip fill-faces for curves & fonts */
|
|
|
|
|
if (ELEM(ob_type, OB_FONT, OB_CURVE)) {
|
|
|
|
|
dl_mask &= ~((1 << DL_INDEX3) | (1 << DL_INDEX4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return drawDispListwire_ex(dlbase, dl_mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool index3_nors_incr = true;
|
|
|
|
|
|
2012-09-25 13:31:46 +00:00
|
|
|
static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag,
|
2013-03-24 12:13:13 +00:00
|
|
|
const unsigned char ob_wire_col[4], const bool use_glsl)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
GPUVertexAttribs gattribs;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (lb == NULL) return;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-12-09 14:37:26 +00:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2014-01-15 00:35:43 +11:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
if (ob->type == OB_MBALL) { /* mball always smooth shaded */
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
DispList *dl = lb->first;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (dl) {
|
2015-12-16 01:24:15 -05:00
|
|
|
const float *data = dl->verts;
|
|
|
|
|
const float *ndata = dl->nors;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (dl->type) {
|
2012-03-18 06:01:33 +00:00
|
|
|
case DL_SEGM:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob->type == OB_SURF) {
|
2012-09-25 13:31:46 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0)
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
// glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
|
|
|
|
// glDrawArrays(GL_LINE_STRIP, 0, dl->nr);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int nr = dl->nr; nr; nr--, data += 3)
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(data);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
2012-03-18 06:01:33 +00:00
|
|
|
case DL_POLY:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob->type == OB_SURF) {
|
2012-03-18 06:01:33 +00:00
|
|
|
/* for some reason glDrawArrays crashes here in half of the platforms (not osx) */
|
|
|
|
|
//glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
|
|
|
|
//glDrawArrays(GL_LINE_LOOP, 0, dl->nr);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_LOOP);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int nr = dl->nr; nr; nr--, data += 3)
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(data);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
2013-07-28 11:15:26 +00:00
|
|
|
break;
|
2012-03-18 06:01:33 +00:00
|
|
|
case DL_SURF:
|
|
|
|
|
|
|
|
|
|
if (dl->index) {
|
2015-12-16 01:24:15 -05:00
|
|
|
GPU_object_material_bind(dl->col + 1, use_glsl ? &gattribs : NULL);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH);
|
|
|
|
|
else glShadeModel(GL_FLAT);
|
|
|
|
|
|
|
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
|
|
|
|
glNormalPointer(GL_FLOAT, 0, dl->nors);
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawElements(GL_QUADS, 4 * dl->totindex, GL_UNSIGNED_INT, dl->index);
|
2012-03-18 06:01:33 +00:00
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DL_INDEX3:
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_bind(dl->col + 1, (use_glsl) ? &gattribs : NULL);
|
2009-12-09 14:37:26 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
|
|
|
|
|
2012-05-26 13:31:57 +00:00
|
|
|
/* for polys only one normal needed */
|
2012-03-18 06:01:33 +00:00
|
|
|
if (index3_nors_incr) {
|
|
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
glNormalPointer(GL_FLOAT, 0, dl->nors);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
glNormal3fv(ndata);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
if (index3_nors_incr)
|
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DL_INDEX4:
|
2015-11-23 21:42:17 +01:00
|
|
|
GPU_object_material_bind(dl->col + 1, (use_glsl) ? &gattribs : NULL);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2009-12-09 14:37:26 +00:00
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
|
2009-12-09 14:37:26 +00:00
|
|
|
glNormalPointer(GL_FLOAT, 0, dl->nors);
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index);
|
2009-12-09 14:37:26 +00:00
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
dl = dl->next;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-09 14:37:26 +00:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
|
glFrontFace(GL_CCW);
|
2015-11-27 21:32:14 +01:00
|
|
|
|
|
|
|
|
GPU_object_material_unbind();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-05 16:47:52 +00:00
|
|
|
static void drawCurveDMWired(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
DerivedMesh *dm = ob->derivedFinal;
|
2012-03-25 23:54:33 +00:00
|
|
|
dm->drawEdges(dm, 1, 0);
|
2010-03-05 16:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/* return true when nothing was drawn */
|
|
|
|
|
static bool drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt)
|
2010-03-05 16:47:52 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
2010-03-05 16:47:52 +00:00
|
|
|
DerivedMesh *dm = ob->derivedFinal;
|
|
|
|
|
|
|
|
|
|
if (!dm) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2010-03-05 16:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-10 01:16:17 +03:00
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
|
2014-01-15 00:35:43 +11:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
|
|
|
|
|
2015-08-01 14:42:14 +10:00
|
|
|
if (dt > OB_WIRE && dm->getNumPolys(dm)) {
|
2015-12-16 01:24:15 -05:00
|
|
|
bool glsl = draw_glsl_material(scene, ob, v3d, dt);
|
2010-03-05 16:47:52 +00:00
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
|
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
if (!glsl)
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
|
2010-09-20 21:57:29 +00:00
|
|
|
else
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesGLSL(dm, GPU_object_material_bind);
|
2010-03-05 16:47:52 +00:00
|
|
|
|
|
|
|
|
GPU_end_object_materials();
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0)
|
|
|
|
|
drawCurveDMWired(ob);
|
2010-03-05 16:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2010-03-05 16:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-14 14:47:45 +00:00
|
|
|
/**
|
|
|
|
|
* Only called by #drawDispList
|
2015-03-30 00:51:00 -04:00
|
|
|
* \return true when nothing was drawn
|
2012-11-14 14:47:45 +00:00
|
|
|
*/
|
2013-03-24 12:13:13 +00:00
|
|
|
static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|
|
|
|
const char dt, const short dflag, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
|
|
|
|
ListBase *lb = NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
DispList *dl;
|
|
|
|
|
Curve *cu;
|
2015-02-03 09:32:19 +11:00
|
|
|
const bool render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
|
|
|
|
|
const bool solid = (dt > OB_WIRE);
|
2012-05-25 09:26:47 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (ob->type) {
|
2012-03-18 06:01:33 +00:00
|
|
|
case OB_FONT:
|
|
|
|
|
case OB_CURVE:
|
2012-03-25 23:54:33 +00:00
|
|
|
cu = ob->data;
|
2009-09-08 07:35:07 +00:00
|
|
|
|
2013-08-19 09:25:24 +00:00
|
|
|
lb = &ob->curve_cache->disp;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
if (solid) {
|
2014-06-04 08:36:22 +10:00
|
|
|
const bool has_faces = BKE_displist_has_faces(lb);
|
2012-03-25 23:54:33 +00:00
|
|
|
dl = lb->first;
|
2012-11-14 14:47:45 +00:00
|
|
|
if (dl == NULL) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2012-11-14 14:47:45 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-05-07 06:58:03 +00:00
|
|
|
if (dl->nors == NULL) BKE_displist_normals_add(lb);
|
2013-03-24 12:13:13 +00:00
|
|
|
index3_nors_incr = false;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2014-06-04 08:36:22 +10:00
|
|
|
if (!render_only) {
|
|
|
|
|
/* when we have faces, only draw loose-wire */
|
|
|
|
|
if (has_faces) {
|
|
|
|
|
drawDispListwire_ex(lb, (1 << DL_SEGM));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
drawDispListwire(lb, ob->type);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-06-04 08:36:22 +10:00
|
|
|
|
|
|
|
|
if (has_faces == false) {
|
|
|
|
|
/* pass */
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else {
|
2012-03-18 06:01:33 +00:00
|
|
|
if (draw_glsl_material(scene, ob, v3d, dt)) {
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
|
2013-03-24 12:13:13 +00:00
|
|
|
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
|
2012-03-18 06:01:33 +00:00
|
|
|
GPU_end_object_materials();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
|
2013-03-24 12:13:13 +00:00
|
|
|
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
|
2012-03-18 06:01:33 +00:00
|
|
|
GPU_end_object_materials();
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) {
|
2012-03-18 06:01:33 +00:00
|
|
|
cpack(0);
|
2014-06-04 08:36:22 +10:00
|
|
|
drawDispListwire(lb, ob->type);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
index3_nors_incr = true;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-07 06:58:03 +00:00
|
|
|
if (!render_only || (render_only && BKE_displist_has_faces(lb))) {
|
2014-06-04 08:36:22 +10:00
|
|
|
return drawDispListwire(lb, ob->type);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
|
|
|
|
case OB_SURF:
|
2009-09-08 07:35:07 +00:00
|
|
|
|
2013-08-19 09:25:24 +00:00
|
|
|
lb = &ob->curve_cache->disp;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (solid) {
|
2012-03-25 23:54:33 +00:00
|
|
|
dl = lb->first;
|
2012-11-14 14:47:45 +00:00
|
|
|
if (dl == NULL) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2012-11-14 14:47:45 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-05-07 06:58:03 +00:00
|
|
|
if (dl->nors == NULL) BKE_displist_normals_add(lb);
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw_glsl_material(scene, ob, v3d, dt)) {
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
|
2013-03-24 12:13:13 +00:00
|
|
|
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_end_object_materials();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
|
2013-03-24 12:13:13 +00:00
|
|
|
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_end_object_materials();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
else {
|
2014-06-04 08:36:22 +10:00
|
|
|
return drawDispListwire(lb, ob->type);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
|
|
|
|
case OB_MBALL:
|
|
|
|
|
|
2012-05-07 06:38:41 +00:00
|
|
|
if (BKE_mball_is_basis(ob)) {
|
2014-01-13 16:18:08 +06:00
|
|
|
lb = &ob->curve_cache->disp;
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(lb)) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2012-11-14 14:47:45 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
if (solid) {
|
|
|
|
|
|
|
|
|
|
if (draw_glsl_material(scene, ob, v3d, dt)) {
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
|
2013-03-24 12:13:13 +00:00
|
|
|
drawDispListsolid(lb, ob, dflag, ob_wire_col, true);
|
2012-03-18 06:01:33 +00:00
|
|
|
GPU_end_object_materials();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
|
2013-03-24 12:13:13 +00:00
|
|
|
drawDispListsolid(lb, ob, dflag, ob_wire_col, false);
|
2012-03-18 06:01:33 +00:00
|
|
|
GPU_end_object_materials();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else {
|
2014-06-04 08:36:22 +10:00
|
|
|
return drawDispListwire(lb, ob->type);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-11-14 14:47:45 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2012-11-14 14:47:45 +00:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|
|
|
|
const char dt, const short dflag, const unsigned char ob_wire_col[4])
|
2012-11-14 14:47:45 +00:00
|
|
|
{
|
2013-03-24 12:13:13 +00:00
|
|
|
bool retval;
|
2012-11-14 14:47:45 +00:00
|
|
|
|
|
|
|
|
/* backface culling */
|
|
|
|
|
if (v3d->flag2 & V3D_BACKFACE_CULLING) {
|
|
|
|
|
/* not all displists use same in/out normal direction convention */
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
2013-09-17 14:20:00 +00:00
|
|
|
glCullFace(GL_BACK);
|
2012-11-14 14:47:45 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-12 14:06:13 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
ensure_curve_cache(scene, base->object);
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-02-27 20:54:57 +11:00
|
|
|
if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == false) {
|
2015-02-27 20:58:32 +11:00
|
|
|
retval = false;
|
2015-02-27 20:54:57 +11:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Object *ob = base->object;
|
|
|
|
|
GLenum mode;
|
|
|
|
|
|
|
|
|
|
if (ob->type == OB_MBALL) {
|
|
|
|
|
mode = (ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mode = (ob->transflag & OB_NEG_SCALE) ? GL_CCW : GL_CW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glFrontFace(mode);
|
|
|
|
|
|
|
|
|
|
retval = drawDispList_nobackface(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
|
|
|
|
|
|
|
|
|
if (mode != GL_CCW) {
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-14 14:47:45 +00:00
|
|
|
|
|
|
|
|
if (v3d->flag2 & V3D_BACKFACE_CULLING) {
|
2012-05-25 09:26:47 +00:00
|
|
|
glDisable(GL_CULL_FACE);
|
2012-11-14 14:47:45 +00:00
|
|
|
}
|
2012-05-25 09:26:47 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-19 18:45:31 +00:00
|
|
|
/* *********** drawing for particles ************* */
|
2009-10-05 13:25:56 +00:00
|
|
|
static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select)
|
|
|
|
|
{
|
|
|
|
|
/* draw created data arrays */
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (draw_as) {
|
2009-10-05 13:25:56 +00:00
|
|
|
case PART_DRAW_AXIS:
|
|
|
|
|
case PART_DRAW_CROSS:
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawArrays(GL_LINES, 0, 6 * totpoint);
|
2009-10-05 13:25:56 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_LINE:
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawArrays(GL_LINES, 0, 2 * totpoint);
|
2009-10-05 13:25:56 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_BB:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob_dt <= OB_WIRE || select)
|
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
2009-10-05 13:25:56 +00:00
|
|
|
else
|
2012-03-18 06:01:33 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawArrays(GL_QUADS, 0, 4 * totpoint);
|
2009-10-05 13:25:56 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
glDrawArrays(GL_POINTS, 0, totpoint);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-12-03 20:49:41 +00:00
|
|
|
static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize,
|
2013-05-08 12:57:07 +00:00
|
|
|
float imat[4][4], const float draw_line[2], ParticleBillboardData *bb, ParticleDrawData *pdd)
|
2009-07-04 03:50:12 +00:00
|
|
|
{
|
|
|
|
|
float vec[3], vec2[3];
|
2010-10-25 17:20:12 +00:00
|
|
|
float *vd = NULL;
|
|
|
|
|
float *cd = NULL;
|
2012-03-25 23:54:33 +00:00
|
|
|
float ma_col[3] = {0.0f, 0.0f, 0.0f};
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-10-25 17:20:12 +00:00
|
|
|
/* null only for PART_DRAW_CIRC */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd) {
|
2010-10-25 17:20:12 +00:00
|
|
|
vd = pdd->vd;
|
|
|
|
|
cd = pdd->cd;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd->ma_col) {
|
2011-11-26 13:11:55 +00:00
|
|
|
copy_v3_v3(ma_col, pdd->ma_col);
|
2010-10-25 17:20:12 +00:00
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (draw_as) {
|
2009-07-04 03:50:12 +00:00
|
|
|
case PART_DRAW_DOT:
|
|
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (vd) {
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(vd, state->co); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (cd) {
|
2011-11-26 13:11:55 +00:00
|
|
|
copy_v3_v3(cd, pdd->ma_col);
|
2012-03-25 23:54:33 +00:00
|
|
|
pdd->cd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case PART_DRAW_CROSS:
|
|
|
|
|
case PART_DRAW_AXIS:
|
|
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0] = 2.0f * pixsize;
|
|
|
|
|
vec[1] = vec[2] = 0.0;
|
|
|
|
|
mul_qt_v3(state->rot, vec);
|
|
|
|
|
if (draw_as == PART_DRAW_AXIS) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (cd) {
|
2012-03-25 23:54:33 +00:00
|
|
|
cd[1] = cd[2] = cd[4] = cd[5] = 0.0;
|
|
|
|
|
cd[0] = cd[3] = 1.0;
|
|
|
|
|
cd[6] = cd[8] = cd[9] = cd[11] = 0.0;
|
|
|
|
|
cd[7] = cd[10] = 1.0;
|
|
|
|
|
cd[13] = cd[12] = cd[15] = cd[16] = 0.0;
|
|
|
|
|
cd[14] = cd[17] = 1.0;
|
|
|
|
|
pdd->cd += 18;
|
2011-01-09 15:28:43 +00:00
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(vec2, state->co);
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (cd) {
|
2012-03-25 23:54:33 +00:00
|
|
|
cd[0] = cd[3] = cd[6] = cd[9] = cd[12] = cd[15] = ma_col[0];
|
|
|
|
|
cd[1] = cd[4] = cd[7] = cd[10] = cd[13] = cd[16] = ma_col[1];
|
|
|
|
|
cd[2] = cd[5] = cd[8] = cd[11] = cd[14] = cd[17] = ma_col[2];
|
|
|
|
|
pdd->cd += 18;
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2010-08-01 11:00:36 +00:00
|
|
|
sub_v3_v3v3(vec2, state->co, vec);
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(vec, state->co);
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
|
|
|
|
|
copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[1] = 2.0f * pixsize;
|
|
|
|
|
vec[0] = vec[2] = 0.0;
|
|
|
|
|
mul_qt_v3(state->rot, vec);
|
|
|
|
|
if (draw_as == PART_DRAW_AXIS) {
|
|
|
|
|
copy_v3_v3(vec2, state->co);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
|
sub_v3_v3v3(vec2, state->co, vec);
|
|
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(vec, state->co);
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
|
|
|
|
|
copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 2.0f * pixsize;
|
2015-03-30 00:51:00 -04:00
|
|
|
vec[0] = vec[1] = 0.0f;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_qt_v3(state->rot, vec);
|
|
|
|
|
if (draw_as == PART_DRAW_AXIS) {
|
|
|
|
|
copy_v3_v3(vec2, state->co);
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
|
sub_v3_v3v3(vec2, state->co, vec);
|
|
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(vec, state->co);
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
|
|
|
|
|
copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case PART_DRAW_LINE:
|
|
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(vec, state->vel);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(vec);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw & PART_DRAW_VEL_LENGTH)
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_v3_fl(vec, len_v3(state->vel));
|
|
|
|
|
madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd += 3;
|
|
|
|
|
madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd += 3;
|
2012-02-22 16:52:06 +00:00
|
|
|
if (cd) {
|
2012-03-25 23:54:33 +00:00
|
|
|
cd[0] = cd[3] = ma_col[0];
|
|
|
|
|
cd[1] = cd[4] = ma_col[1];
|
|
|
|
|
cd[2] = cd[5] = ma_col[2];
|
|
|
|
|
pdd->cd += 6;
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case PART_DRAW_CIRC:
|
|
|
|
|
{
|
|
|
|
|
drawcircball(GL_LINE_LOOP, state->co, pixsize, imat);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case PART_DRAW_BB:
|
|
|
|
|
{
|
|
|
|
|
float xvec[3], yvec[3], zvec[3], bb_center[3];
|
2012-02-22 16:52:06 +00:00
|
|
|
if (cd) {
|
2012-03-25 23:54:33 +00:00
|
|
|
cd[0] = cd[3] = cd[6] = cd[9] = ma_col[0];
|
|
|
|
|
cd[1] = cd[4] = cd[7] = cd[10] = ma_col[1];
|
|
|
|
|
cd[2] = cd[5] = cd[8] = cd[11] = ma_col[2];
|
|
|
|
|
pdd->cd += 12;
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
copy_v3_v3(bb->vec, state->co);
|
|
|
|
|
copy_v3_v3(bb->vel, state->vel);
|
2009-07-04 03:50:12 +00:00
|
|
|
|
|
|
|
|
psys_make_billboard(bb, xvec, yvec, zvec, bb_center);
|
|
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3v3(pdd->vd, bb_center, xvec);
|
2012-03-25 23:54:33 +00:00
|
|
|
add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-09-01 10:29:03 +00:00
|
|
|
sub_v3_v3v3(pdd->vd, bb_center, xvec);
|
2012-03-25 23:54:33 +00:00
|
|
|
add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
sub_v3_v3v3(pdd->vd, bb_center, xvec);
|
2012-03-25 23:54:33 +00:00
|
|
|
sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3v3(pdd->vd, bb_center, xvec);
|
2012-03-25 23:54:33 +00:00
|
|
|
sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
|
|
|
|
|
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
|
|
|
|
|
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
|
|
|
|
|
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
|
2009-07-04 03:50:12 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-08 12:57:07 +00:00
|
|
|
static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
|
|
|
|
|
ParticleKey *state, int draw_as,
|
|
|
|
|
float imat[4][4], ParticleBillboardData *bb, ParticleDrawData *pdd,
|
|
|
|
|
const float ct, const float pa_size, const float r_tilt, const float pixsize_scale)
|
|
|
|
|
{
|
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
float pixsize;
|
|
|
|
|
|
|
|
|
|
if (psys->parent)
|
|
|
|
|
mul_m4_v3(psys->parent->obmat, state->co);
|
|
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* create actual particle data */
|
2013-05-08 12:57:07 +00:00
|
|
|
if (draw_as == PART_DRAW_BB) {
|
|
|
|
|
bb->offset[0] = part->bb_offset[0];
|
|
|
|
|
bb->offset[1] = part->bb_offset[1];
|
|
|
|
|
bb->size[0] = part->bb_size[0] * pa_size;
|
|
|
|
|
if (part->bb_align == PART_BB_VEL) {
|
|
|
|
|
float pa_vel = len_v3(state->vel);
|
|
|
|
|
float head = part->bb_vel_head * pa_vel;
|
|
|
|
|
float tail = part->bb_vel_tail * pa_vel;
|
|
|
|
|
bb->size[1] = part->bb_size[1] * pa_size + head + tail;
|
|
|
|
|
/* use offset to adjust the particle center. this is relative to size, so need to divide! */
|
|
|
|
|
if (bb->size[1] > 0.0f)
|
|
|
|
|
bb->offset[1] += (head - tail) / bb->size[1];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bb->size[1] = part->bb_size[1] * pa_size;
|
|
|
|
|
}
|
|
|
|
|
bb->tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
|
|
|
|
|
bb->time = ct;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixsize = ED_view3d_pixel_size(rv3d, state->co) * pixsize_scale;
|
|
|
|
|
|
|
|
|
|
draw_particle(state, draw_as, part->draw, pixsize, imat, part->draw_line, bb, pdd);
|
|
|
|
|
}
|
2015-03-30 00:51:00 -04:00
|
|
|
/* unified drawing of all new particle systems draw types except dupli ob & group
|
|
|
|
|
* mostly tries to use vertex arrays for speed
|
|
|
|
|
*
|
|
|
|
|
* 1. check that everything is ok & updated
|
|
|
|
|
* 2. start initializing things
|
|
|
|
|
* 3. initialize according to draw type
|
|
|
|
|
* 4. allocate drawing data arrays
|
|
|
|
|
* 5. start filling the arrays
|
|
|
|
|
* 6. draw the arrays
|
|
|
|
|
* 7. clean up
|
|
|
|
|
*/
|
2011-12-03 20:49:41 +00:00
|
|
|
static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv3d,
|
2014-06-04 14:22:29 +10:00
|
|
|
Base *base, ParticleSystem *psys,
|
|
|
|
|
const char ob_dt, const short dflag)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
2009-08-29 15:20:36 +00:00
|
|
|
ParticleEditSettings *pset = PE_settings(scene);
|
2012-02-25 08:37:51 +00:00
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
ParticleData *pars = psys->particles;
|
|
|
|
|
ParticleData *pa;
|
2012-03-25 23:54:33 +00:00
|
|
|
ParticleKey state, *states = NULL;
|
2009-04-20 15:06:46 +00:00
|
|
|
ParticleBillboardData bb;
|
2012-03-25 23:54:33 +00:00
|
|
|
ParticleSimulationData sim = {NULL};
|
2009-09-17 22:00:49 +00:00
|
|
|
ParticleDrawData *pdd = psys->pdd;
|
2008-12-19 12:14:58 +00:00
|
|
|
Material *ma;
|
2009-07-04 03:50:12 +00:00
|
|
|
float vel[3], imat[4][4];
|
2012-07-25 12:55:55 +00:00
|
|
|
float timestep, pixsize_scale = 1.0f, pa_size, r_tilt, r_length;
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
|
2011-01-12 03:41:12 +00:00
|
|
|
float cfra;
|
2012-03-25 23:54:33 +00:00
|
|
|
float ma_col[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
int a, totpart, totpoint = 0, totve = 0, drawn, draw_as, totchild = 0;
|
2014-04-01 11:34:00 +11:00
|
|
|
bool select = (ob->flag & SELECT) != 0, create_cdata = false, need_v = false;
|
2008-12-19 12:14:58 +00:00
|
|
|
GLint polygonmode[2];
|
2012-01-11 09:33:44 +00:00
|
|
|
char numstr[32];
|
2012-03-25 23:54:33 +00:00
|
|
|
unsigned char tcol[4] = {0, 0, 0, 255};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* 1. */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part == NULL || !psys_check_enabled(ob, psys))
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pars == NULL) return;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-08-29 15:20:36 +00:00
|
|
|
/* don't draw normal paths in edit mode */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART) == 0)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (part->draw_as == PART_DRAW_REND)
|
2009-10-05 13:25:56 +00:00
|
|
|
draw_as = part->ren_as;
|
|
|
|
|
else
|
|
|
|
|
draw_as = part->draw_as;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw_as == PART_DRAW_NOT)
|
2009-10-05 13:25:56 +00:00
|
|
|
return;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-03-25 20:08:12 +01:00
|
|
|
/* prepare curvemapping tables */
|
|
|
|
|
if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve)
|
|
|
|
|
curvemapping_changed_all(psys->part->clumpcurve);
|
|
|
|
|
if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve)
|
|
|
|
|
curvemapping_changed_all(psys->part->roughcurve);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* 2. */
|
2012-03-25 23:54:33 +00:00
|
|
|
sim.scene = scene;
|
|
|
|
|
sim.ob = ob;
|
|
|
|
|
sim.psys = psys;
|
|
|
|
|
sim.psmd = psys_get_modifier(ob, psys);
|
2009-09-17 22:00:49 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part->phystype == PART_PHYS_KEYED) {
|
|
|
|
|
if (psys->flag & PSYS_KEYED) {
|
2009-09-17 22:00:49 +00:00
|
|
|
psys_count_keyed_targets(&sim);
|
2012-03-25 23:54:33 +00:00
|
|
|
if (psys->totkeyed == 0)
|
2009-07-12 23:38:47 +00:00
|
|
|
return;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (select) {
|
2015-12-16 01:24:15 -05:00
|
|
|
select = false;
|
2012-03-25 23:54:33 +00:00
|
|
|
if (psys_get_current(ob) == psys)
|
2015-12-16 01:24:15 -05:00
|
|
|
select = true;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
psys->flag |= PSYS_DRAWING;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part->type == PART_HAIR && !psys->childcache)
|
|
|
|
|
totchild = 0;
|
2010-07-17 17:07:50 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
totchild = psys->totchild * part->disp / 100;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
ma = give_current_material(ob, part->omat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->zbuf) glDepthMask(1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if ((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
|
2012-01-19 09:09:00 +00:00
|
|
|
rgb_float_to_uchar(tcol, &(ma->r));
|
2011-11-26 13:11:55 +00:00
|
|
|
copy_v3_v3(ma_col, &ma->r);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2010-12-20 03:59:22 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(tcol);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
timestep = psys_get_timestep(&sim);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
float mat[4][4];
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, ob->obmat, psys->imat);
|
2010-02-01 15:32:55 +00:00
|
|
|
glMultMatrixf(mat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-03 11:40:12 +00:00
|
|
|
/* needed for text display */
|
|
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
totpart = psys->totpart;
|
2009-06-05 23:59:33 +00:00
|
|
|
|
2012-05-05 14:33:36 +00:00
|
|
|
cfra = BKE_scene_frame_get(scene);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL)
|
|
|
|
|
draw_as = PART_DRAW_DOT;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* 3. */
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (draw_as) {
|
2008-12-19 12:14:58 +00:00
|
|
|
case PART_DRAW_DOT:
|
2012-02-22 16:52:06 +00:00
|
|
|
if (part->draw_size)
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(part->draw_size);
|
|
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
glPointSize(2.0); /* default dot size */
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_CIRC:
|
|
|
|
|
/* calculate view aligned matrix: */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(imat, rv3d->viewinv);
|
|
|
|
|
normalize_v3(imat[0]);
|
|
|
|
|
normalize_v3(imat[1]);
|
2013-07-21 08:16:37 +00:00
|
|
|
/* fall-through */
|
2008-12-19 12:14:58 +00:00
|
|
|
case PART_DRAW_CROSS:
|
|
|
|
|
case PART_DRAW_AXIS:
|
|
|
|
|
/* lets calculate the scale: */
|
2010-11-19 16:19:15 +00:00
|
|
|
|
2012-02-01 06:26:48 +00:00
|
|
|
if (part->draw_size == 0.0)
|
|
|
|
|
pixsize_scale = 2.0f;
|
2010-11-19 16:19:15 +00:00
|
|
|
else
|
2012-02-01 06:26:48 +00:00
|
|
|
pixsize_scale = part->draw_size;
|
2009-10-05 13:25:56 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (draw_as == PART_DRAW_AXIS)
|
2009-10-05 13:25:56 +00:00
|
|
|
create_cdata = 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_OB:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part->dup_ob == NULL)
|
|
|
|
|
draw_as = PART_DRAW_DOT;
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
draw_as = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_GR:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part->dup_group == NULL)
|
|
|
|
|
draw_as = PART_DRAW_DOT;
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
draw_as = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_BB:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (v3d->camera == NULL && part->bb_ob == NULL) {
|
2008-12-19 17:14:02 +00:00
|
|
|
printf("Billboards need an active camera or a target object!\n");
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
draw_as = part->draw_as = PART_DRAW_DOT;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (part->draw_size)
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(part->draw_size);
|
|
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
glPointSize(2.0); /* default dot size */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (part->bb_ob)
|
2012-03-25 23:54:33 +00:00
|
|
|
bb.ob = part->bb_ob;
|
2008-12-19 12:14:58 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
bb.ob = v3d->camera;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
bb.align = part->bb_align;
|
|
|
|
|
bb.anim = part->bb_anim;
|
|
|
|
|
bb.lock = part->draw & PART_DRAW_BB_LOCK;
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_PATH:
|
|
|
|
|
break;
|
2009-07-04 03:50:12 +00:00
|
|
|
case PART_DRAW_LINE:
|
2012-03-25 23:54:33 +00:00
|
|
|
need_v = 1;
|
2009-07-04 03:50:12 +00:00
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part->draw & PART_DRAW_SIZE && part->draw_as != PART_DRAW_CIRC) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(imat, rv3d->viewinv);
|
|
|
|
|
normalize_v3(imat[0]);
|
|
|
|
|
normalize_v3(imat[1]);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(draw_as, PART_DRAW_DOT, PART_DRAW_CROSS, PART_DRAW_LINE) &&
|
2012-04-21 15:11:03 +00:00
|
|
|
(part->draw_col > PART_DRAW_COL_MAT))
|
2012-03-18 06:01:33 +00:00
|
|
|
{
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
create_cdata = 1;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!create_cdata && pdd && pdd->cdata) {
|
2009-10-05 13:25:56 +00:00
|
|
|
MEM_freeN(pdd->cdata);
|
|
|
|
|
pdd->cdata = pdd->cd = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* 4. */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (draw_as && ELEM(draw_as, PART_DRAW_PATH, PART_DRAW_CIRC) == 0) {
|
2009-04-20 15:06:46 +00:00
|
|
|
int tot_vec_size = (totpart + totchild) * 3 * sizeof(float);
|
2009-10-05 13:25:56 +00:00
|
|
|
int create_ndata = 0;
|
2009-09-17 22:00:49 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!pdd)
|
2015-03-30 00:51:00 -04:00
|
|
|
pdd = psys->pdd = MEM_callocN(sizeof(ParticleDrawData), "ParticleDrawData");
|
2009-09-17 22:00:49 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
|
2009-07-04 03:50:12 +00:00
|
|
|
tot_vec_size *= part->trail_count;
|
2009-07-12 23:38:47 +00:00
|
|
|
psys_make_temp_pointcache(ob, psys);
|
|
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (draw_as) {
|
2009-10-05 13:25:56 +00:00
|
|
|
case PART_DRAW_AXIS:
|
|
|
|
|
case PART_DRAW_CROSS:
|
|
|
|
|
tot_vec_size *= 6;
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw_as != PART_DRAW_CROSS)
|
2009-10-05 13:25:56 +00:00
|
|
|
create_cdata = 1;
|
|
|
|
|
break;
|
|
|
|
|
case PART_DRAW_LINE:
|
|
|
|
|
tot_vec_size *= 2;
|
|
|
|
|
break;
|
|
|
|
|
case PART_DRAW_BB:
|
|
|
|
|
tot_vec_size *= 4;
|
|
|
|
|
create_ndata = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd->tot_vec_size != tot_vec_size)
|
2009-09-17 22:00:49 +00:00
|
|
|
psys_free_pdd(psys);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!pdd->vdata)
|
2009-10-05 13:25:56 +00:00
|
|
|
pdd->vdata = MEM_callocN(tot_vec_size, "particle_vdata");
|
2012-02-22 16:52:06 +00:00
|
|
|
if (create_cdata && !pdd->cdata)
|
2009-10-05 13:25:56 +00:00
|
|
|
pdd->cdata = MEM_callocN(tot_vec_size, "particle_cdata");
|
2012-02-22 16:52:06 +00:00
|
|
|
if (create_ndata && !pdd->ndata)
|
Completely refactored sph fluid particles. Only the very core of the algorithm remains
the same, but big changes have happened both on the outside and on the inside.
New UI:
* The old parameters were quite true to the underlying algorithm, but were quite obscure
from a users point of view. Now there are only a few intuitive basic parameters that
define the basic fluid behavior.
** By default particle size is now used to determine the interaction radius, rest
density and spring rest lengths so that it's easy to get stable simulations by simply
emitting particles for a few frames and adjusting the particle size (easy when the
particle size is drawn) so that the fluid appears continuous (particles are touching
eachother).
** Stiffness - in reality most fluids are very incompressible, but this is a very hard
problem to solve with particle based fluid simulation so some compromises have to be
made. So the bigger the stiffness parameter is the less the fluid will compress under
stress, but the more substeps are needed for stable simulation.
** Viscosity - how much internal friction there is in the fluid. Large viscosities also
smooth out instabilities, so less viscous fluids again need more substeps to remain
stable.
** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against
gravity, and high pressure areas start to come down.
* In addition to these basic parameters there are separate advanced parameters that can
either be tweaked relative to the basic parameters (or particle size) or defined
independently.
** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this
can lead to small clumps of particles, so the repulsion keeps the particles better
separated.
** Stiff viscosity - the normal viscosity only applies when particles are moving closer to
eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to
particles that are moving away from eachother.
** Interaction radius - by default this is 4 * particle size.
** Rest density - by default this is a density that the particles have when they're packed
densely next to eachother.
** Spring rest length - by default this is 2 * particle size.
* There are also new options for 3d view particle coloring in the display panel to show
particle velocity and acceleration. These make it easier to see what's happening in the
fluid simulations, but can of course be used with other particles as well.
* Viscoelastic springs have some new options too. The plasticity can now be set to much
higher values for instant deletion of springs as the elastic limit is exeeded. In addition
to that there is an option to only create springs for a certain number of frames when a
particle is born. These options give new possibilities for breaking viscoelastic fluids.
New in the code:
* Most of the fluids code is now thread safe, so when particle dynamics go threaded there
will be a nice speed boost to fluids as well.
* Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree
implementation makes the code quite a bit cleaner and should also give a slight speed
boost to the simulation too.
* Previously only force fields were calculated with the different integration methods, but
now the fluid calculations are also done using the selected integration method, so there
are again more choices in effecting simulation accuracy and stability. This change also
included a nice cleanup of the whole particle integration code.
As the internals are pretty stirred up old particle fluid simulations will probably not
work correctly straight away, but with some tweaking the same level of control is still
available by not using the "relative versions" of the advanced parameters (by default these
are not used when loading old files).
2011-03-12 12:38:11 +00:00
|
|
|
pdd->ndata = MEM_callocN(tot_vec_size, "particle_ndata");
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (part->draw & PART_DRAW_VEL && draw_as != PART_DRAW_LINE) {
|
|
|
|
|
if (!pdd->vedata)
|
2009-10-05 13:25:56 +00:00
|
|
|
pdd->vedata = MEM_callocN(2 * (totpart + totchild) * 3 * sizeof(float), "particle_vedata");
|
|
|
|
|
|
2009-07-04 03:50:12 +00:00
|
|
|
need_v = 1;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (pdd->vedata) {
|
2009-12-03 00:42:02 +00:00
|
|
|
/* velocity data not needed, so free it */
|
|
|
|
|
MEM_freeN(pdd->vedata);
|
2012-03-25 23:54:33 +00:00
|
|
|
pdd->vedata = NULL;
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
pdd->vd = pdd->vdata;
|
|
|
|
|
pdd->ved = pdd->vedata;
|
|
|
|
|
pdd->cd = pdd->cdata;
|
|
|
|
|
pdd->nd = pdd->ndata;
|
|
|
|
|
pdd->tot_vec_size = tot_vec_size;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (psys->pdd) {
|
2011-01-15 12:29:22 +00:00
|
|
|
psys_free_pdd(psys);
|
|
|
|
|
MEM_freeN(psys->pdd);
|
|
|
|
|
pdd = psys->pdd = NULL;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd) {
|
2012-03-25 23:54:33 +00:00
|
|
|
pdd->ma_col = ma_col;
|
2010-10-25 17:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
|
2009-10-05 13:25:56 +00:00
|
|
|
|
2010-10-25 17:20:12 +00:00
|
|
|
/* circles don't use drawdata, so have to add a special case here */
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((pdd || draw_as == PART_DRAW_CIRC) && draw_as != PART_DRAW_PATH) {
|
2012-03-25 23:12:42 +00:00
|
|
|
/* 5. */
|
2012-03-18 06:01:33 +00:00
|
|
|
if (pdd && (pdd->flag & PARTICLE_DRAW_DATA_UPDATED) &&
|
2012-03-25 23:54:33 +00:00
|
|
|
(pdd->vedata || part->draw & (PART_DRAW_SIZE | PART_DRAW_NUM | PART_DRAW_HEALTH)) == 0)
|
2012-03-18 06:01:33 +00:00
|
|
|
{
|
2009-09-17 22:00:49 +00:00
|
|
|
totpoint = pdd->totpoint; /* draw data is up to date */
|
|
|
|
|
}
|
2012-03-25 23:12:42 +00:00
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = 0, pa = pars; a < totpart + totchild; a++, pa++) {
|
2012-03-25 23:12:42 +00:00
|
|
|
/* setup per particle individual stuff */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (a < totpart) {
|
|
|
|
|
if (totchild && (part->draw & PART_DRAW_PARENT) == 0) continue;
|
2012-03-25 23:12:42 +00:00
|
|
|
if (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
pa_time = (cfra - pa->time) / pa->lifetime;
|
|
|
|
|
pa_birthtime = pa->time;
|
2012-03-25 23:12:42 +00:00
|
|
|
pa_dietime = pa->dietime;
|
2012-03-25 23:54:33 +00:00
|
|
|
pa_size = pa->size;
|
|
|
|
|
if (part->phystype == PART_PHYS_BOIDS)
|
2012-03-25 23:12:42 +00:00
|
|
|
pa_health = pa->boid->data.health;
|
|
|
|
|
else
|
|
|
|
|
pa_health = -1.0;
|
|
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
r_tilt = 2.0f * (psys_frand(psys, a + 21) - 0.5f);
|
|
|
|
|
r_length = psys_frand(psys, a + 22);
|
2012-03-25 23:12:42 +00:00
|
|
|
|
|
|
|
|
if (part->draw_col > PART_DRAW_COL_MAT) {
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (part->draw_col) {
|
2012-03-25 23:12:42 +00:00
|
|
|
case PART_DRAW_COL_VEL:
|
2012-03-25 23:54:33 +00:00
|
|
|
intensity = len_v3(pa->state.vel) / part->color_vec_max;
|
2012-03-25 23:12:42 +00:00
|
|
|
break;
|
|
|
|
|
case PART_DRAW_COL_ACC:
|
|
|
|
|
intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2012-03-25 23:54:33 +00:00
|
|
|
intensity = 1.0f; /* should never happen */
|
2013-07-21 08:16:37 +00:00
|
|
|
BLI_assert(0);
|
|
|
|
|
break;
|
2012-03-25 23:12:42 +00:00
|
|
|
}
|
2015-04-13 16:56:43 -04:00
|
|
|
CLAMP(intensity, 0.0f, 1.0f);
|
2012-03-25 23:12:42 +00:00
|
|
|
weight_to_rgb(ma_col, intensity);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:12:42 +00:00
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
ChildParticle *cpa = &psys->child[a - totpart];
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);
|
|
|
|
|
pa_size = psys_get_child_size(psys, cpa, cfra, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
pa_health = -1.0;
|
2009-10-05 13:25:56 +00:00
|
|
|
|
2014-03-07 10:25:56 +01:00
|
|
|
r_tilt = 2.0f * (psys_frand(psys, a + 21) - 0.5f);
|
|
|
|
|
r_length = psys_frand(psys, a + 22);
|
2012-03-25 23:12:42 +00:00
|
|
|
}
|
2012-02-01 06:26:48 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
drawn = 0;
|
|
|
|
|
if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
|
|
|
|
|
float length = part->path_end * (1.0f - part->randlength * r_length);
|
|
|
|
|
int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
|
|
|
|
|
float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
|
|
|
|
|
float dt = length / (trail_count ? (float)trail_count : 1.0f);
|
2012-03-25 23:54:33 +00:00
|
|
|
int i = 0;
|
2012-03-25 23:12:42 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
ct += dt;
|
|
|
|
|
for (i = 0; i < trail_count; i++, ct += dt) {
|
2012-03-25 23:12:42 +00:00
|
|
|
|
|
|
|
|
if (part->draw & PART_ABS_PATH_TIME) {
|
|
|
|
|
if (ct < pa_birthtime || ct > pa_dietime)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (ct < 0.0f || ct > 1.0f)
|
2009-07-04 03:50:12 +00:00
|
|
|
continue;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
|
2012-03-25 23:54:33 +00:00
|
|
|
psys_get_particle_on_path(&sim, a, &state, need_v);
|
2012-03-25 23:12:42 +00:00
|
|
|
|
2013-05-08 12:57:07 +00:00
|
|
|
draw_particle_data(psys, rv3d,
|
|
|
|
|
&state, draw_as, imat, &bb, psys->pdd,
|
|
|
|
|
ct, pa_size, r_tilt, pixsize_scale);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
totpoint++;
|
|
|
|
|
drawn = 1;
|
|
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2012-03-25 23:12:42 +00:00
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
state.time = cfra;
|
|
|
|
|
if (psys_get_particle_state(&sim, a, &state, 0)) {
|
2012-02-01 06:26:48 +00:00
|
|
|
|
2013-05-08 12:57:07 +00:00
|
|
|
draw_particle_data(psys, rv3d,
|
|
|
|
|
&state, draw_as, imat, &bb, psys->pdd,
|
|
|
|
|
pa_time, pa_size, r_tilt, pixsize_scale);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
totpoint++;
|
|
|
|
|
drawn = 1;
|
|
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
if (drawn) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* additional things to draw for each particle
|
|
|
|
|
* (velocity, size and number) */
|
2012-03-25 23:12:42 +00:00
|
|
|
if ((part->draw & PART_DRAW_VEL) && pdd && pdd->vedata) {
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(pdd->ved, state.co);
|
2012-03-25 23:12:42 +00:00
|
|
|
pdd->ved += 3;
|
|
|
|
|
mul_v3_v3fl(vel, state.vel, timestep);
|
|
|
|
|
add_v3_v3v3(pdd->ved, state.co, vel);
|
2012-03-25 23:54:33 +00:00
|
|
|
pdd->ved += 3;
|
2012-03-25 23:12:42 +00:00
|
|
|
|
|
|
|
|
totve++;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
if (part->draw & PART_DRAW_SIZE) {
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
drawcircball(GL_LINE_LOOP, state.co, pa_size, imat);
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-03-16 17:49:31 +00:00
|
|
|
|
2012-03-25 23:12:42 +00:00
|
|
|
if ((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) &&
|
|
|
|
|
(v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
|
|
|
|
|
{
|
2014-04-17 15:14:07 +10:00
|
|
|
size_t numstr_len;
|
2012-03-25 23:12:42 +00:00
|
|
|
float vec_txt[3];
|
2012-03-25 23:54:33 +00:00
|
|
|
char *val_pos = numstr;
|
|
|
|
|
numstr[0] = '\0';
|
2010-03-03 11:23:59 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (part->draw & PART_DRAW_NUM) {
|
|
|
|
|
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
|
2012-03-25 23:12:42 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d", a);
|
2012-03-25 23:12:42 +00:00
|
|
|
}
|
2010-10-30 23:02:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
|
2015-04-22 05:37:22 +10:00
|
|
|
numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%.2f", pa_health);
|
2012-03-25 23:12:42 +00:00
|
|
|
}
|
2010-10-30 23:02:38 +00:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2014-04-17 15:14:07 +10:00
|
|
|
if (numstr[0]) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* in path drawing state.co is the end point
|
|
|
|
|
* use worldspace because object matrix is already applied */
|
2014-04-17 15:14:07 +10:00
|
|
|
mul_v3_m4v3(vec_txt, ob->imat, state.co);
|
|
|
|
|
view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
|
|
|
|
|
10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
|
|
|
|
|
}
|
2012-03-25 23:12:42 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
/* 6. */
|
|
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
glGetIntegerv(GL_POLYGON_MODE, polygonmode);
|
2009-12-09 14:37:26 +00:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (draw_as == PART_DRAW_PATH) {
|
2009-10-05 13:25:56 +00:00
|
|
|
ParticleCacheKey **cache, *path;
|
2015-03-30 01:25:34 -04:00
|
|
|
float *cdata2 = NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
/* setup gl flags */
|
2010-05-04 12:31:24 +00:00
|
|
|
if (1) { //ob_dt > OB_WIRE) {
|
2009-10-05 13:25:56 +00:00
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (part->draw_col == PART_DRAW_COL_MAT)
|
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
// XXX test
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f);
|
|
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
|
2012-03-03 16:31:46 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (totchild && (part->draw & PART_DRAW_PARENT) == 0)
|
|
|
|
|
totpart = 0;
|
|
|
|
|
else if (psys->pathcache == NULL)
|
|
|
|
|
totpart = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
/* draw actual/parent particles */
|
2012-03-25 23:54:33 +00:00
|
|
|
cache = psys->pathcache;
|
|
|
|
|
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
|
|
|
|
|
path = cache[a];
|
2015-01-13 17:24:20 +01:00
|
|
|
if (path->segments > 0) {
|
2009-04-20 15:06:46 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (1) { //ob_dt > OB_WIRE) {
|
2009-04-20 15:06:46 +00:00
|
|
|
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (part->draw_col == PART_DRAW_COL_MAT) {
|
|
|
|
|
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
|
2009-04-20 15:06:46 +00:00
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
2014-10-03 16:46:08 +02:00
|
|
|
|
|
|
|
|
if (part->type == PART_HAIR) {
|
|
|
|
|
if (part->draw & PART_DRAW_GUIDE_HAIRS) {
|
2014-11-13 15:15:02 +01:00
|
|
|
DerivedMesh *hair_dm = psys->hair_out_dm;
|
|
|
|
|
|
2014-10-03 16:46:08 +02:00
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
2014-11-13 15:15:02 +01:00
|
|
|
|
2014-10-03 16:46:08 +02:00
|
|
|
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
|
|
|
|
|
if (pa->totkey > 1) {
|
|
|
|
|
HairKey *hkey = pa->hair;
|
|
|
|
|
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, sizeof(HairKey), hkey->world_co);
|
2015-03-30 00:51:00 -04:00
|
|
|
|
|
|
|
|
#if 0 /* XXX use proper theme color here */
|
|
|
|
|
UI_ThemeColor(TH_NORMAL);
|
|
|
|
|
#else
|
2014-10-03 16:46:08 +02:00
|
|
|
glColor3f(0.58f, 0.67f, 1.0f);
|
2015-03-30 00:51:00 -04:00
|
|
|
#endif
|
|
|
|
|
|
2014-10-03 16:46:08 +02:00
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, pa->totkey);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-13 15:15:02 +01:00
|
|
|
|
|
|
|
|
if (hair_dm) {
|
|
|
|
|
MVert *mvert = hair_dm->getVertArray(hair_dm);
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
glColor3f(0.9f, 0.4f, 0.4f);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
|
|
|
|
|
for (i = 1; i < pa->totkey; ++i) {
|
|
|
|
|
float v1[3], v2[3];
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(v1, mvert[pa->hair_index + i - 1].co);
|
|
|
|
|
copy_v3_v3(v2, mvert[pa->hair_index + i].co);
|
|
|
|
|
|
|
|
|
|
mul_m4_v3(ob->obmat, v1);
|
|
|
|
|
mul_m4_v3(ob->obmat, v2);
|
|
|
|
|
|
|
|
|
|
glVertex3fv(v1);
|
|
|
|
|
glVertex3fv(v2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-03 16:46:08 +02:00
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0)
|
|
|
|
|
if (part->draw_col == PART_DRAW_COL_MAT)
|
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
}
|
2014-10-31 14:23:32 +01:00
|
|
|
|
|
|
|
|
if (part->draw & PART_DRAW_HAIR_GRID) {
|
|
|
|
|
ClothModifierData *clmd = psys->clmd;
|
|
|
|
|
if (clmd) {
|
2015-11-23 15:44:15 +11:00
|
|
|
float *gmin = clmd->hair_grid_min;
|
|
|
|
|
float *gmax = clmd->hair_grid_max;
|
2014-10-31 14:23:32 +01:00
|
|
|
int *res = clmd->hair_grid_res;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
|
|
|
|
|
if (select)
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE);
|
|
|
|
|
else
|
|
|
|
|
UI_ThemeColor(TH_WIRE);
|
|
|
|
|
glBegin(GL_LINES);
|
2015-11-23 15:44:15 +11:00
|
|
|
glVertex3f(gmin[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmin[1], gmin[2]);
|
|
|
|
|
glVertex3f(gmax[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmin[2]);
|
|
|
|
|
glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmin[2]);
|
|
|
|
|
glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmin[1], gmin[2]);
|
2014-10-31 14:23:32 +01:00
|
|
|
|
2015-11-23 15:44:15 +11:00
|
|
|
glVertex3f(gmin[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmin[1], gmax[2]);
|
|
|
|
|
glVertex3f(gmax[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmax[1], gmax[2]);
|
|
|
|
|
glVertex3f(gmax[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmax[1], gmax[2]);
|
|
|
|
|
glVertex3f(gmin[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmin[1], gmax[2]);
|
2014-10-31 14:23:32 +01:00
|
|
|
|
2015-11-23 15:44:15 +11:00
|
|
|
glVertex3f(gmin[0], gmin[1], gmin[2]); glVertex3f(gmin[0], gmin[1], gmax[2]);
|
|
|
|
|
glVertex3f(gmax[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmin[1], gmax[2]);
|
|
|
|
|
glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmax[2]);
|
|
|
|
|
glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmax[2]);
|
2014-10-31 14:23:32 +01:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
if (select)
|
|
|
|
|
UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -100);
|
|
|
|
|
else
|
|
|
|
|
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -100);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBegin(GL_LINES);
|
2015-06-17 07:06:59 +10:00
|
|
|
for (i = 1; i < res[0] - 1; ++i) {
|
2015-11-23 15:44:15 +11:00
|
|
|
float f = interpf(gmax[0], gmin[0], (float)i / (float)(res[0] - 1));
|
|
|
|
|
glVertex3f(f, gmin[1], gmin[2]); glVertex3f(f, gmax[1], gmin[2]);
|
|
|
|
|
glVertex3f(f, gmax[1], gmin[2]); glVertex3f(f, gmax[1], gmax[2]);
|
|
|
|
|
glVertex3f(f, gmax[1], gmax[2]); glVertex3f(f, gmin[1], gmax[2]);
|
|
|
|
|
glVertex3f(f, gmin[1], gmax[2]); glVertex3f(f, gmin[1], gmin[2]);
|
2014-10-31 14:23:32 +01:00
|
|
|
}
|
2015-06-17 07:06:59 +10:00
|
|
|
for (i = 1; i < res[1] - 1; ++i) {
|
2015-11-23 15:44:15 +11:00
|
|
|
float f = interpf(gmax[1], gmin[1], (float)i / (float)(res[1] - 1));
|
|
|
|
|
glVertex3f(gmin[0], f, gmin[2]); glVertex3f(gmax[0], f, gmin[2]);
|
|
|
|
|
glVertex3f(gmax[0], f, gmin[2]); glVertex3f(gmax[0], f, gmax[2]);
|
|
|
|
|
glVertex3f(gmax[0], f, gmax[2]); glVertex3f(gmin[0], f, gmax[2]);
|
|
|
|
|
glVertex3f(gmin[0], f, gmax[2]); glVertex3f(gmin[0], f, gmin[2]);
|
2014-10-31 14:23:32 +01:00
|
|
|
}
|
2015-06-17 07:06:59 +10:00
|
|
|
for (i = 1; i < res[2] - 1; ++i) {
|
2015-11-23 15:44:15 +11:00
|
|
|
float f = interpf(gmax[2], gmin[2], (float)i / (float)(res[2] - 1));
|
|
|
|
|
glVertex3f(gmin[0], gmin[1], f); glVertex3f(gmax[0], gmin[1], f);
|
|
|
|
|
glVertex3f(gmax[0], gmin[1], f); glVertex3f(gmax[0], gmax[1], f);
|
|
|
|
|
glVertex3f(gmax[0], gmax[1], f); glVertex3f(gmin[0], gmax[1], f);
|
|
|
|
|
glVertex3f(gmin[0], gmax[1], f); glVertex3f(gmin[0], gmin[1], f);
|
2014-10-31 14:23:32 +01:00
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0)
|
|
|
|
|
if (part->draw_col == PART_DRAW_COL_MAT)
|
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-03 16:46:08 +02:00
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
|
|
|
|
|
/* draw child particles */
|
2012-03-25 23:54:33 +00:00
|
|
|
cache = psys->childcache;
|
|
|
|
|
for (a = 0; a < totchild; a++) {
|
|
|
|
|
path = cache[a];
|
2009-10-05 13:25:56 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (1) { //ob_dt > OB_WIRE) {
|
2009-10-05 13:25:56 +00:00
|
|
|
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (part->draw_col == PART_DRAW_COL_MAT) {
|
|
|
|
|
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* restore & clean up */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (1) { //ob_dt > OB_WIRE) {
|
|
|
|
|
if (part->draw_col == PART_DRAW_COL_MAT)
|
2014-09-25 23:11:51 +02:00
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
|
2009-04-20 15:06:46 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-03-30 01:25:34 -04:00
|
|
|
if (cdata2) {
|
2009-10-05 13:25:56 +00:00
|
|
|
MEM_freeN(cdata2);
|
2015-03-30 01:25:34 -04:00
|
|
|
cdata2 = NULL;
|
|
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
|
|
|
|
|
glLineWidth(1.0f);
|
2010-06-22 15:02:23 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
|
|
|
|
|
cache = psys->pathcache;
|
2010-06-22 15:02:23 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
|
2010-06-22 15:02:23 +00:00
|
|
|
float vec_txt[3];
|
2015-11-23 15:44:15 +11:00
|
|
|
size_t numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%i", a);
|
2015-03-30 00:51:00 -04:00
|
|
|
/* use worldspace because object matrix is already applied */
|
2010-06-22 15:02:23 +00:00
|
|
|
mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
|
|
|
|
|
10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
|
2010-06-22 15:02:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (pdd && ELEM(draw_as, 0, PART_DRAW_CIRC) == 0) {
|
2009-10-05 13:25:56 +00:00
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
|
|
|
|
|
/* enable point data array */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd->vdata) {
|
2009-10-05 13:25:56 +00:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, pdd->vdata);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (select) {
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if (part->draw_size)
|
|
|
|
|
glPointSize(part->draw_size + 2);
|
|
|
|
|
else
|
|
|
|
|
glPointSize(4.0);
|
|
|
|
|
|
|
|
|
|
glLineWidth(3.0);
|
|
|
|
|
|
|
|
|
|
draw_particle_arrays(draw_as, totpoint, ob_dt, 1);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
/* restore from select */
|
|
|
|
|
glColor3fv(ma_col);
|
2009-10-05 13:25:56 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
glPointSize(part->draw_size ? part->draw_size : 2.0);
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
|
|
|
|
|
|
/* enable other data arrays */
|
2009-09-17 22:00:49 +00:00
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
/* billboards are drawn this way */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pdd->ndata && ob_dt > OB_WIRE) {
|
2009-10-05 13:25:56 +00:00
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
glNormalPointer(GL_FLOAT, 0, pdd->ndata);
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f);
|
|
|
|
|
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if (pdd->cdata) {
|
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
draw_particle_arrays(draw_as, totpoint, ob_dt, 0);
|
|
|
|
|
|
|
|
|
|
pdd->flag |= PARTICLE_DRAW_DATA_UPDATED;
|
|
|
|
|
pdd->totpoint = totpoint;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd && pdd->vedata) {
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
|
cpack(0xC0C0C0);
|
|
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, 0, pdd->vedata);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glDrawArrays(GL_LINES, 0, 2 * totve);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
glPolygonMode(GL_FRONT, polygonmode[0]);
|
|
|
|
|
glPolygonMode(GL_BACK, polygonmode[1]);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* 7. */
|
|
|
|
|
|
2015-12-05 22:11:31 +01:00
|
|
|
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
2009-12-09 14:37:26 +00:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (states)
|
2008-12-19 12:14:58 +00:00
|
|
|
MEM_freeN(states);
|
|
|
|
|
|
|
|
|
|
psys->flag &= ~PSYS_DRAWING;
|
|
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
/* draw data can't be saved for billboards as they must update to target changes */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (draw_as == PART_DRAW_BB) {
|
2009-10-05 13:25:56 +00:00
|
|
|
psys_free_pdd(psys);
|
|
|
|
|
pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-19 10:11:48 +00:00
|
|
|
if (psys->lattice_deform_data) {
|
|
|
|
|
end_latt_deform(psys->lattice_deform_data);
|
|
|
|
|
psys->lattice_deform_data = NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pdd) {
|
2011-02-12 16:54:24 +00:00
|
|
|
/* drop references to stack memory */
|
2012-03-25 23:54:33 +00:00
|
|
|
pdd->ma_col = NULL;
|
2011-02-12 16:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2011-02-12 16:54:24 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-07 17:55:58 +00:00
|
|
|
static void draw_update_ptcache_edit(Scene *scene, Object *ob, PTCacheEdit *edit)
|
|
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED)
|
2009-12-07 17:55:58 +00:00
|
|
|
PE_update_object(scene, ob, 0);
|
|
|
|
|
|
|
|
|
|
/* create path and child path cache if it doesn't exist already */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (edit->pathcache == NULL)
|
2009-12-07 17:55:58 +00:00
|
|
|
psys_cache_edit_paths(scene, ob, edit, CFRA);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2009-08-29 15:20:36 +00:00
|
|
|
ParticleCacheKey **cache, *path, *pkey;
|
|
|
|
|
PTCacheEditPoint *point;
|
|
|
|
|
PTCacheEditKey *key;
|
2009-01-24 13:45:24 +00:00
|
|
|
ParticleEditSettings *pset = PE_settings(scene);
|
2015-06-04 15:28:26 +10:00
|
|
|
int i, k, totpoint = edit->totpoint, timed = (pset->flag & PE_FADE_TIME) ? pset->fade_frames : 0;
|
2015-01-13 17:24:20 +01:00
|
|
|
int totkeys = 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
float sel_col[3];
|
|
|
|
|
float nosel_col[3];
|
2009-08-29 15:20:36 +00:00
|
|
|
float *pathcol = NULL, *pcol;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (edit->pathcache == NULL)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
|
2009-08-29 15:20:36 +00:00
|
|
|
PE_hide_keys_time(scene, edit, CFRA);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* opengl setup */
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((v3d->flag & V3D_ZBUF_SELECT) == 0)
|
2008-12-19 12:14:58 +00:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
|
|
/* get selection theme colors */
|
2009-12-03 00:42:02 +00:00
|
|
|
UI_GetThemeColor3fv(TH_VERTEX_SELECT, sel_col);
|
|
|
|
|
UI_GetThemeColor3fv(TH_VERTEX, nosel_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw paths */
|
2015-01-13 17:24:20 +01:00
|
|
|
totkeys = (*edit->pathcache)->segments + 1;
|
2013-05-16 00:07:01 +00:00
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
2015-01-13 17:24:20 +01:00
|
|
|
pathcol = MEM_callocN(totkeys * 4 * sizeof(float), "particle path color data");
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2009-08-29 15:20:36 +00:00
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-01-14 09:01:57 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
if (pset->brushtype == PE_BRUSH_WEIGHT)
|
2010-01-14 08:53:10 +00:00
|
|
|
glLineWidth(2.0f);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
cache = edit->pathcache;
|
2013-05-16 00:07:01 +00:00
|
|
|
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
|
2009-08-29 15:20:36 +00:00
|
|
|
path = cache[i];
|
|
|
|
|
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
|
|
|
|
|
|
2013-05-16 00:07:01 +00:00
|
|
|
if (point->flag & PEP_HIDE) {
|
2015-01-13 17:24:20 +01:00
|
|
|
for (k = 0, pcol = pathcol; k < totkeys; k++, pcol += 4) {
|
2013-05-16 00:07:01 +00:00
|
|
|
copy_v3_v3(pcol, path->col);
|
|
|
|
|
pcol[3] = 0.25f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glColorPointer(4, GL_FLOAT, 4 * sizeof(float), pathcol);
|
|
|
|
|
}
|
|
|
|
|
else if (timed) {
|
2015-01-13 17:24:20 +01:00
|
|
|
for (k = 0, pcol = pathcol, pkey = path; k < totkeys; k++, pkey++, pcol += 4) {
|
2010-08-01 11:00:36 +00:00
|
|
|
copy_v3_v3(pcol, pkey->col);
|
2012-03-25 23:54:33 +00:00
|
|
|
pcol[3] = 1.0f - fabsf((float)(CFRA) -pkey->time) / (float)pset->fade_frames;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColorPointer(4, GL_FLOAT, 4 * sizeof(float), pathcol);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-08-29 15:20:36 +00:00
|
|
|
else
|
|
|
|
|
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-01-13 17:24:20 +01:00
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pathcol) { MEM_freeN(pathcol); pathcol = pcol = NULL; }
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* draw edit vertices */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pset->selectmode != SCE_SELECT_PATH) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pset->selectmode == SCE_SELECT_POINT) {
|
|
|
|
|
float *pd = NULL, *pdata = NULL;
|
|
|
|
|
float *cd = NULL, *cdata = NULL;
|
2015-11-23 15:44:15 +11:00
|
|
|
int totkeys_visible = 0;
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (i = 0, point = edit->points; i < totpoint; i++, point++)
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(point->flag & PEP_HIDE))
|
2015-11-23 15:44:15 +11:00
|
|
|
totkeys_visible += point->totkey;
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2015-11-23 15:44:15 +11:00
|
|
|
if (totkeys_visible) {
|
2012-12-14 09:47:05 +00:00
|
|
|
if (edit->points && !(edit->points->keys->flag & PEK_USE_WCO))
|
2015-11-23 15:44:15 +11:00
|
|
|
pd = pdata = MEM_callocN(totkeys_visible * 3 * sizeof(float), "particle edit point data");
|
|
|
|
|
cd = cdata = MEM_callocN(totkeys_visible * (timed ? 4 : 3) * sizeof(float), "particle edit color data");
|
2012-12-14 09:47:05 +00:00
|
|
|
}
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (point->flag & PEP_HIDE)
|
2009-08-29 15:20:36 +00:00
|
|
|
continue;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pd) {
|
2010-08-01 11:00:36 +00:00
|
|
|
copy_v3_v3(pd, key->co);
|
2009-08-29 15:20:36 +00:00
|
|
|
pd += 3;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (key->flag & PEK_SELECT) {
|
|
|
|
|
copy_v3_v3(cd, sel_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(cd, nosel_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (timed)
|
2012-03-25 23:54:33 +00:00
|
|
|
*(cd + 3) = 1.0f - fabsf((float)CFRA - *key->time) / (float)pset->fade_frames;
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
cd += (timed ? 4 : 3);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
cd = cdata;
|
|
|
|
|
pd = pdata;
|
|
|
|
|
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
|
2012-03-20 12:59:45 +00:00
|
|
|
if (point->flag & PEP_HIDE || point->totkey == 0)
|
2009-08-29 15:20:36 +00:00
|
|
|
continue;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (point->keys->flag & PEK_USE_WCO)
|
2009-08-29 15:20:36 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, sizeof(PTCacheEditKey), point->keys->world_co);
|
|
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), pd);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColorPointer((timed ? 4 : 3), GL_FLOAT, (timed ? 4 : 3) * sizeof(float), cd);
|
2009-08-29 15:20:36 +00:00
|
|
|
|
|
|
|
|
glDrawArrays(GL_POINTS, 0, point->totkey);
|
|
|
|
|
|
|
|
|
|
pd += pd ? 3 * point->totkey : 0;
|
2012-03-25 23:54:33 +00:00
|
|
|
cd += (timed ? 4 : 3) * point->totkey;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pdata) { MEM_freeN(pdata); pd = pdata = NULL; }
|
|
|
|
|
if (cdata) { MEM_freeN(cdata); cd = cdata = NULL; }
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (pset->selectmode == SCE_SELECT_END) {
|
2012-03-25 23:54:33 +00:00
|
|
|
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
|
|
|
|
|
if ((point->flag & PEP_HIDE) == 0 && point->totkey) {
|
2009-08-29 15:20:36 +00:00
|
|
|
key = point->keys + point->totkey - 1;
|
2012-02-22 16:52:06 +00:00
|
|
|
if (key->flag & PEK_SELECT)
|
2008-12-19 12:14:58 +00:00
|
|
|
glColor3fv(sel_col);
|
|
|
|
|
else
|
|
|
|
|
glColor3fv(nosel_col);
|
|
|
|
|
/* has to be like this.. otherwise selection won't work, have try glArrayElement later..*/
|
|
|
|
|
glBegin(GL_POINTS);
|
2015-06-04 15:28:26 +10:00
|
|
|
glVertex3fv((key->flag & PEK_USE_WCO) ? key->world_co : key->co);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
2009-12-09 14:37:26 +00:00
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2010-01-14 09:01:57 +00:00
|
|
|
glShadeModel(GL_FLAT);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
2008-12-19 12:14:58 +00:00
|
|
|
glLineWidth(1.0f);
|
2015-03-30 00:51:00 -04:00
|
|
|
glPointSize(1.0f);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2015-03-30 01:25:34 -04:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, float ith, float drw_size)
|
2009-11-21 22:45:25 +00:00
|
|
|
{
|
2009-11-26 00:15:26 +00:00
|
|
|
float tr[3][3];
|
2012-03-25 23:54:33 +00:00
|
|
|
float root[3], tip[3];
|
2009-11-26 00:15:26 +00:00
|
|
|
/* take a copy for not spoiling original */
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_m3_m3(tr, rotscale);
|
2015-12-16 01:24:15 -05:00
|
|
|
float tw = itw * drw_size;
|
|
|
|
|
float th = ith * drw_size;
|
2009-11-26 00:15:26 +00:00
|
|
|
|
|
|
|
|
glColor4ub(0x7F, 0x00, 0x00, 155);
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
root[1] = root[2] = 0.0f;
|
|
|
|
|
root[0] = -drw_size;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
2009-11-26 00:15:26 +00:00
|
|
|
tip[1] = tip[2] = 0.0f;
|
|
|
|
|
tip[0] = drw_size;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, tip);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(tip, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[1] = 0.0f; root[2] = tw;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[0] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
2009-11-21 22:45:25 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[1] = 0.0f; root[2] = -tw;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[0] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
2009-11-21 22:45:25 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
root[1] = tw; root[2] = 0.0f;
|
|
|
|
|
root[0] = th;
|
2009-11-26 00:15:26 +00:00
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
2009-11-21 22:45:25 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[1] = -tw; root[2] = 0.0f;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[0] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glColor4ub(0x00, 0x7F, 0x00, 155);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
root[0] = root[2] = 0.0f;
|
|
|
|
|
root[1] = -drw_size;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
2009-11-26 00:15:26 +00:00
|
|
|
tip[0] = tip[2] = 0.0f;
|
|
|
|
|
tip[1] = drw_size;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, tip);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(tip, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[0] = 0.0f; root[2] = tw;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[1] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
root[0] = 0.0f; root[2] = -tw;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[1] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
root[0] = tw; root[2] = 0.0f;
|
|
|
|
|
root[1] = th;
|
2009-11-26 00:15:26 +00:00
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[0] = -tw; root[2] = 0.0f;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[1] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
glColor4ub(0x00, 0x00, 0x7F, 155);
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
root[0] = root[1] = 0.0f;
|
|
|
|
|
root[2] = -drw_size;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
2009-11-26 00:15:26 +00:00
|
|
|
tip[0] = tip[1] = 0.0f;
|
|
|
|
|
tip[2] = drw_size;
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, tip);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(tip, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[0] = 0.0f; root[1] = tw;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[2] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
root[0] = 0.0f; root[1] = -tw;
|
2009-11-26 00:15:26 +00:00
|
|
|
root[2] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
root[0] = tw; root[1] = 0.0f;
|
|
|
|
|
root[2] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
root[0] = -tw; root[1] = 0.0f;
|
|
|
|
|
root[2] = th;
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m3_v3(tr, root);
|
2010-08-01 11:00:36 +00:00
|
|
|
add_v3_v3(root, com);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(root);
|
|
|
|
|
glVertex3fv(tip);
|
2009-11-26 00:15:26 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-01-23 11:24:48 +00:00
|
|
|
/* place to add drawers */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-06-11 05:56:02 +00:00
|
|
|
static void drawhandlesN(Nurb *nu, const char sel, const bool hide_handles)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->hide || hide_handles) return;
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
glBegin(GL_LINES);
|
2011-09-17 07:14:39 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2011-09-17 07:14:39 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
const float *fp;
|
|
|
|
|
|
2011-09-17 07:14:39 +00:00
|
|
|
#define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1)
|
2012-03-18 07:38:51 +00:00
|
|
|
/* use MIN2 when indexing to ensure newer files don't read outside the array */
|
2011-09-17 07:14:39 +00:00
|
|
|
unsigned char handle_cols[TH_HANDLE_COL_TOT][3];
|
2012-03-25 23:54:33 +00:00
|
|
|
const int basecol = sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
|
2011-09-17 07:14:39 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int a = 0; a < TH_HANDLE_COL_TOT; a++) {
|
2011-09-17 07:14:39 +00:00
|
|
|
UI_GetThemeColor3ubv(basecol + a, handle_cols[a]);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
BezTriple *bezt = nu->bezt;
|
|
|
|
|
int a = nu->pntsu;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bezt->hide == 0) {
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((bezt->f2 & SELECT) == sel) {
|
2012-03-25 23:54:33 +00:00
|
|
|
fp = bezt->vec[0];
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(fp);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(fp + 3);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
|
|
|
|
|
glVertex3fv(fp + 3);
|
|
|
|
|
glVertex3fv(fp + 6);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-09-09 00:00:21 +00:00
|
|
|
else if ((bezt->f1 & SELECT) == sel) {
|
2012-03-25 23:54:33 +00:00
|
|
|
fp = bezt->vec[0];
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT - 1)]);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(fp);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(fp + 3);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-09-09 00:00:21 +00:00
|
|
|
else if ((bezt->f3 & SELECT) == sel) {
|
2012-03-25 23:54:33 +00:00
|
|
|
fp = bezt->vec[1];
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT - 1)]);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(fp);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(fp + 3);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
2011-09-17 07:14:39 +00:00
|
|
|
|
|
|
|
|
#undef TH_HANDLE_COL_TOT
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:42:12 +00:00
|
|
|
static void drawhandlesN_active(Nurb *nu)
|
2010-03-12 16:43:04 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->hide) return;
|
2010-03-12 16:43:04 +00:00
|
|
|
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE_SPLINE);
|
|
|
|
|
glLineWidth(2);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2015-12-16 01:24:15 -05:00
|
|
|
BezTriple *bezt = nu->bezt;
|
|
|
|
|
int a = nu->pntsu;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bezt->hide == 0) {
|
2015-12-16 01:24:15 -05:00
|
|
|
const float *fp = bezt->vec[0];
|
2010-03-12 16:43:04 +00:00
|
|
|
|
|
|
|
|
glVertex3fv(fp);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(fp + 3);
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3fv(fp + 3);
|
|
|
|
|
glVertex3fv(fp + 6);
|
2010-03-12 16:43:04 +00:00
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ub(0, 0, 0);
|
2010-03-12 16:43:04 +00:00
|
|
|
glLineWidth(1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-27 15:18:40 +11:00
|
|
|
static void drawvertsN(Nurb *nu, const char sel, const bool hide_handles, const void *vert)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->hide) return;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
const int color = sel ? TH_VERTEX_SELECT : TH_VERTEX;
|
2010-04-30 04:48:40 +00:00
|
|
|
|
|
|
|
|
UI_ThemeColor(color);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
BezTriple *bezt = nu->bezt;
|
|
|
|
|
int a = nu->pntsu;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bezt->hide == 0) {
|
2014-01-27 15:18:40 +11:00
|
|
|
if (sel == 1 && bezt == vert) {
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE_VERT);
|
2010-04-30 04:48:40 +00:00
|
|
|
|
2015-07-09 14:52:01 +10:00
|
|
|
if (bezt->f2 & SELECT) bglVertex3fv(bezt->vec[1]);
|
2010-04-30 04:48:40 +00:00
|
|
|
if (!hide_handles) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (bezt->f1 & SELECT) bglVertex3fv(bezt->vec[0]);
|
|
|
|
|
if (bezt->f3 & SELECT) bglVertex3fv(bezt->vec[2]);
|
2010-04-30 04:48:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_ThemeColor(color);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else if (hide_handles) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((bezt->f2 & SELECT) == sel) bglVertex3fv(bezt->vec[1]);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((bezt->f1 & SELECT) == sel) bglVertex3fv(bezt->vec[0]);
|
|
|
|
|
if ((bezt->f2 & SELECT) == sel) bglVertex3fv(bezt->vec[1]);
|
|
|
|
|
if ((bezt->f3 & SELECT) == sel) bglVertex3fv(bezt->vec[2]);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-12-16 01:24:15 -05:00
|
|
|
BPoint *bp = nu->bp;
|
|
|
|
|
int a = nu->pntsu * nu->pntsv;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (a--) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bp->hide == 0) {
|
2014-01-27 15:18:40 +11:00
|
|
|
if (bp == vert) {
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE_VERT);
|
2010-04-30 04:48:40 +00:00
|
|
|
bglVertex3fv(bp->vec);
|
|
|
|
|
UI_ThemeColor(color);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((bp->f1 & SELECT) == sel) bglVertex3fv(bp->vec);
|
2010-04-30 04:48:40 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bglEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 16:43:04 +00:00
|
|
|
static void editnurb_draw_active_poly(Nurb *nu)
|
|
|
|
|
{
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE_SPLINE);
|
|
|
|
|
glLineWidth(2);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
BPoint *bp = nu->bp;
|
|
|
|
|
for (int b = 0; b < nu->pntsv; b++) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->flagu & 1) glBegin(GL_LINE_LOOP);
|
2010-03-12 16:43:04 +00:00
|
|
|
else glBegin(GL_LINE_STRIP);
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int a = 0; a < nu->pntsu; a++, bp++) {
|
2010-03-12 16:43:04 +00:00
|
|
|
glVertex3fv(bp->vec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ub(0, 0, 0);
|
2010-03-12 16:43:04 +00:00
|
|
|
glLineWidth(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void editnurb_draw_active_nurbs(Nurb *nu)
|
|
|
|
|
{
|
|
|
|
|
UI_ThemeColor(TH_ACTIVE_SPLINE);
|
|
|
|
|
glLineWidth(2);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2015-12-16 01:24:15 -05:00
|
|
|
BPoint *bp = nu->bp;
|
|
|
|
|
for (int b = 0; b < nu->pntsv; b++) {
|
|
|
|
|
BPoint *bp1 = bp;
|
2010-03-12 16:43:04 +00:00
|
|
|
bp++;
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int a = nu->pntsu - 1; a > 0; a--, bp++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bp->hide == 0 && bp1->hide == 0) {
|
2010-03-12 16:43:04 +00:00
|
|
|
glVertex3fv(bp->vec);
|
|
|
|
|
glVertex3fv(bp1->vec);
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
bp1 = bp;
|
2010-03-12 16:43:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (nu->pntsv > 1) { /* surface */
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
int ofs = nu->pntsu;
|
|
|
|
|
for (int b = 0; b < nu->pntsu; b++) {
|
|
|
|
|
BPoint *bp1 = nu->bp + b;
|
2012-03-25 23:54:33 +00:00
|
|
|
bp = bp1 + ofs;
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int a = nu->pntsv - 1; a > 0; a--, bp += ofs) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (bp->hide == 0 && bp1->hide == 0) {
|
2010-03-12 16:43:04 +00:00
|
|
|
glVertex3fv(bp->vec);
|
|
|
|
|
glVertex3fv(bp1->vec);
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
bp1 = bp;
|
2010-03-12 16:43:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glColor3ub(0, 0, 0);
|
2010-03-12 16:43:04 +00:00
|
|
|
glLineWidth(1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 12:18:17 +10:00
|
|
|
static void draw_editnurb_splines(Object *ob, Nurb *nurb, const bool sel)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
BPoint *bp, *bp1;
|
2015-12-16 01:24:15 -05:00
|
|
|
int a, b;
|
2015-03-30 00:51:00 -04:00
|
|
|
Curve *cu = ob->data;
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
int index = 0;
|
|
|
|
|
Nurb *nu = nurb;
|
2012-02-22 16:52:06 +00:00
|
|
|
while (nu) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (nu->hide == 0) {
|
|
|
|
|
switch (nu->type) {
|
2012-03-18 06:01:33 +00:00
|
|
|
case CU_POLY:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (!sel && index == cu->actnu) {
|
2012-03-18 06:01:33 +00:00
|
|
|
/* we should draw active spline highlight below everything */
|
|
|
|
|
editnurb_draw_active_poly(nu);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
UI_ThemeColor(TH_NURB_ULINE);
|
2012-03-25 23:54:33 +00:00
|
|
|
bp = nu->bp;
|
|
|
|
|
for (b = 0; b < nu->pntsv; b++) {
|
2012-03-18 06:01:33 +00:00
|
|
|
if (nu->flagu & 1) glBegin(GL_LINE_LOOP);
|
|
|
|
|
else glBegin(GL_LINE_STRIP);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = 0; a < nu->pntsu; a++, bp++) {
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(bp->vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case CU_NURBS:
|
2012-03-25 23:54:33 +00:00
|
|
|
if (!sel && index == cu->actnu) {
|
2012-03-18 06:01:33 +00:00
|
|
|
/* we should draw active spline highlight below everything */
|
|
|
|
|
editnurb_draw_active_nurbs(nu);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
bp = nu->bp;
|
|
|
|
|
for (b = 0; b < nu->pntsv; b++) {
|
|
|
|
|
bp1 = bp;
|
2012-03-18 06:01:33 +00:00
|
|
|
bp++;
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = nu->pntsu - 1; a > 0; a--, bp++) {
|
|
|
|
|
if (bp->hide == 0 && bp1->hide == 0) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (sel) {
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
|
2012-03-18 06:01:33 +00:00
|
|
|
UI_ThemeColor(TH_NURB_SEL_ULINE);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(bp->vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(bp1->vec);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-10 22:00:55 +00:00
|
|
|
if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
|
|
|
|
|
/* pass */
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else {
|
2012-03-18 06:01:33 +00:00
|
|
|
UI_ThemeColor(TH_NURB_ULINE);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(bp->vec);
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(bp1->vec);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
bp1 = bp;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
if (nu->pntsv > 1) { /* surface */
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
int ofs = nu->pntsu;
|
2012-03-25 23:54:33 +00:00
|
|
|
for (b = 0; b < nu->pntsu; b++) {
|
|
|
|
|
bp1 = nu->bp + b;
|
|
|
|
|
bp = bp1 + ofs;
|
|
|
|
|
for (a = nu->pntsv - 1; a > 0; a--, bp += ofs) {
|
|
|
|
|
if (bp->hide == 0 && bp1->hide == 0) {
|
2012-03-18 06:01:33 +00:00
|
|
|
if (sel) {
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
|
2012-03-18 06:01:33 +00:00
|
|
|
UI_ThemeColor(TH_NURB_SEL_VLINE);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(bp->vec);
|
|
|
|
|
glVertex3fv(bp1->vec);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ((bp->f1 & SELECT) && (bp1->f1 & SELECT)) {
|
|
|
|
|
/* pass */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_ThemeColor(TH_NURB_VLINE);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(bp->vec);
|
|
|
|
|
glVertex3fv(bp1->vec);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
bp1 = bp;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-03-12 16:43:04 +00:00
|
|
|
|
2012-05-09 09:24:15 +00:00
|
|
|
index++;
|
2012-03-25 23:54:33 +00:00
|
|
|
nu = nu->next;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 12:18:17 +10:00
|
|
|
static void draw_editnurb(
|
|
|
|
|
Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
|
|
|
|
|
const char dt, const short dflag, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
ToolSettings *ts = scene->toolsettings;
|
|
|
|
|
Object *ob = base->object;
|
2008-12-19 12:14:58 +00:00
|
|
|
Curve *cu = ob->data;
|
|
|
|
|
Nurb *nu;
|
2014-01-27 15:18:40 +11:00
|
|
|
const void *vert = BKE_curve_vert_active_get(cu);
|
2013-06-11 05:56:02 +00:00
|
|
|
const bool hide_handles = (cu->drawflag & CU_HIDE_HANDLES) != 0;
|
2012-06-06 18:00:08 +00:00
|
|
|
unsigned char wire_col[3];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* DispList */
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_WIRE_EDIT, wire_col);
|
2012-06-06 18:00:08 +00:00
|
|
|
glColor3ubv(wire_col);
|
|
|
|
|
|
2012-09-25 13:31:46 +00:00
|
|
|
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-08-26 12:28:41 +10:00
|
|
|
/* for shadows only show solid faces */
|
2015-12-16 01:24:15 -05:00
|
|
|
if (v3d->flag2 & V3D_RENDER_SHADOW)
|
2014-08-26 12:28:41 +10:00
|
|
|
return;
|
|
|
|
|
|
2013-06-11 05:21:36 +00:00
|
|
|
if (v3d->zbuf) glDepthFunc(GL_ALWAYS);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-03-12 16:43:04 +00:00
|
|
|
/* first non-selected and active handles */
|
2015-12-16 01:24:15 -05:00
|
|
|
int index = 0;
|
2012-03-25 23:54:33 +00:00
|
|
|
for (nu = nurb; nu; nu = nu->next) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2010-03-12 16:43:04 +00:00
|
|
|
if (index == cu->actnu && !hide_handles)
|
2013-01-15 15:42:12 +00:00
|
|
|
drawhandlesN_active(nu);
|
|
|
|
|
drawhandlesN(nu, 0, hide_handles);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-05-09 09:24:15 +00:00
|
|
|
index++;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-08-26 12:18:17 +10:00
|
|
|
draw_editnurb_splines(ob, nurb, false);
|
|
|
|
|
draw_editnurb_splines(ob, nurb, true);
|
2008-12-19 12:14:58 +00:00
|
|
|
/* selected handles */
|
2012-03-25 23:54:33 +00:00
|
|
|
for (nu = nurb; nu; nu = nu->next) {
|
|
|
|
|
if (nu->type == CU_BEZIER && (cu->drawflag & CU_HIDE_HANDLES) == 0)
|
2013-01-15 15:42:12 +00:00
|
|
|
drawhandlesN(nu, 1, hide_handles);
|
|
|
|
|
drawvertsN(nu, 0, hide_handles, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-11 05:21:36 +00:00
|
|
|
if (v3d->zbuf) glDepthFunc(GL_LEQUAL);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-08-26 12:28:41 +10:00
|
|
|
glColor3ubv(wire_col);
|
|
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
/* direction vectors for 3d curve paths
|
2012-03-18 07:38:51 +00:00
|
|
|
* when at its lowest, don't render normals */
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) {
|
2015-12-16 01:24:15 -05:00
|
|
|
BevList *bl;
|
2013-08-19 09:25:24 +00:00
|
|
|
for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
|
2014-06-15 14:23:23 +10:00
|
|
|
BevPoint *bevp = bl->bevpoints;
|
2012-03-25 23:54:33 +00:00
|
|
|
int nr = bl->nr;
|
|
|
|
|
int skip = nu->resolu / 16;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
while (nr-- > 0) { /* accounts for empty bevel lists */
|
|
|
|
|
const float fac = bevp->radius * ts->normalsize;
|
2012-07-08 20:36:00 +00:00
|
|
|
float vec_a[3]; /* Offset perpendicular to the curve */
|
|
|
|
|
float vec_b[3]; /* Delta along the curve */
|
2010-11-03 06:31:53 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec_a[0] = fac;
|
|
|
|
|
vec_a[1] = 0.0f;
|
|
|
|
|
vec_a[2] = 0.0f;
|
2009-09-11 15:35:30 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec_b[0] = -fac;
|
|
|
|
|
vec_b[1] = 0.0f;
|
|
|
|
|
vec_b[2] = 0.0f;
|
2010-11-03 06:31:53 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_v3(bevp->quat, vec_a);
|
|
|
|
|
mul_qt_v3(bevp->quat, vec_b);
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(vec_a, bevp->vec);
|
|
|
|
|
add_v3_v3(vec_b, bevp->vec);
|
2011-11-07 01:38:32 +00:00
|
|
|
|
|
|
|
|
madd_v3_v3fl(vec_a, bevp->dir, -fac);
|
|
|
|
|
madd_v3_v3fl(vec_b, bevp->dir, -fac);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2009-09-11 15:35:30 +00:00
|
|
|
glVertex3fv(vec_a);
|
2009-09-10 02:57:25 +00:00
|
|
|
glVertex3fv(bevp->vec);
|
2009-09-11 15:35:30 +00:00
|
|
|
glVertex3fv(vec_b);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
bevp += skip + 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
nr -= skip;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-11 05:56:02 +00:00
|
|
|
if (v3d->zbuf) glDepthFunc(GL_ALWAYS);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (nu = nurb; nu; nu = nu->next) {
|
2014-01-27 15:18:40 +11:00
|
|
|
drawvertsN(nu, 1, hide_handles, vert);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-11 05:56:02 +00:00
|
|
|
if (v3d->zbuf) glDepthFunc(GL_LEQUAL);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-16 17:22:41 +10:00
|
|
|
static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2])
|
|
|
|
|
{
|
|
|
|
|
cpack(0);
|
|
|
|
|
ED_view3d_polygon_offset(rv3d, -1.0);
|
|
|
|
|
set_inverted_drawing(1);
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
glVertex2fv(textcurs[0]);
|
|
|
|
|
glVertex2fv(textcurs[1]);
|
|
|
|
|
glVertex2fv(textcurs[2]);
|
|
|
|
|
glVertex2fv(textcurs[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void draw_editfont(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|
|
|
|
const char dt, const short dflag, const unsigned char ob_wire_col[4])
|
|
|
|
|
{
|
|
|
|
|
Object *ob = base->object;
|
|
|
|
|
Curve *cu = ob->data;
|
|
|
|
|
EditFont *ef = cu->editfont;
|
|
|
|
|
float vec1[3], vec2[3];
|
2015-12-16 01:24:15 -05:00
|
|
|
int selstart, selend;
|
2014-06-16 17:22:41 +10:00
|
|
|
|
|
|
|
|
draw_editfont_textcurs(rv3d, ef->textcurs);
|
|
|
|
|
|
|
|
|
|
if (cu->flag & CU_FAST) {
|
|
|
|
|
cpack(0xFFFFFF);
|
|
|
|
|
set_inverted_drawing(1);
|
|
|
|
|
drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cu->linewidth != 0.0f) {
|
|
|
|
|
UI_ThemeColor(TH_WIRE_EDIT);
|
|
|
|
|
copy_v3_v3(vec1, ob->orig);
|
|
|
|
|
copy_v3_v3(vec2, ob->orig);
|
|
|
|
|
vec1[0] += cu->linewidth;
|
|
|
|
|
vec2[0] += cu->linewidth;
|
|
|
|
|
vec1[1] += cu->linedist * cu->fsize;
|
|
|
|
|
vec2[1] -= cu->lines * cu->linedist * cu->fsize;
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex2fv(vec1);
|
|
|
|
|
glVertex2fv(vec2);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setlinestyle(3);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i < cu->totbox; i++) {
|
2014-06-16 17:22:41 +10:00
|
|
|
if (cu->tb[i].w != 0.0f) {
|
|
|
|
|
UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
|
|
|
|
|
vec1[0] = cu->xof + cu->tb[i].x;
|
|
|
|
|
vec1[1] = cu->yof + cu->tb[i].y + cu->fsize;
|
|
|
|
|
vec1[2] = 0.001;
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(vec1);
|
|
|
|
|
vec1[0] += cu->tb[i].w;
|
|
|
|
|
glVertex3fv(vec1);
|
|
|
|
|
vec1[1] -= cu->tb[i].h;
|
|
|
|
|
glVertex3fv(vec1);
|
|
|
|
|
vec1[0] -= cu->tb[i].w;
|
|
|
|
|
glVertex3fv(vec1);
|
|
|
|
|
vec1[1] += cu->tb[i].h;
|
|
|
|
|
glVertex3fv(vec1);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (BKE_vfont_select_get(ob, &selstart, &selend) && ef->selboxes) {
|
|
|
|
|
const int seltot = selend - selstart;
|
|
|
|
|
float selboxw;
|
|
|
|
|
|
|
|
|
|
cpack(0xffffff);
|
|
|
|
|
set_inverted_drawing(1);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int i = 0; i <= seltot; i++) {
|
2014-06-16 17:22:41 +10:00
|
|
|
EditFontSelBox *sb = &ef->selboxes[i];
|
|
|
|
|
float tvec[3];
|
|
|
|
|
|
|
|
|
|
if (i != seltot) {
|
|
|
|
|
if (ef->selboxes[i + 1].y == sb->y)
|
|
|
|
|
selboxw = ef->selboxes[i + 1].x - sb->x;
|
|
|
|
|
else
|
|
|
|
|
selboxw = sb->w;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
selboxw = sb->w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fill in xy below */
|
|
|
|
|
tvec[2] = 0.001;
|
|
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
|
|
|
|
|
if (sb->rot == 0.0f) {
|
|
|
|
|
copy_v2_fl2(tvec, sb->x, sb->y);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, sb->x + selboxw, sb->y);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, sb->x + selboxw, sb->y + sb->h);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, sb->x, sb->y + sb->h);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float mat[2][2];
|
|
|
|
|
|
|
|
|
|
angle_to_mat2(mat, sb->rot);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, sb->x, sb->y);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, selboxw, 0.0f);
|
|
|
|
|
mul_m2v2(mat, tvec);
|
|
|
|
|
add_v2_v2(tvec, &sb->x);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, selboxw, sb->h);
|
|
|
|
|
mul_m2v2(mat, tvec);
|
|
|
|
|
add_v2_v2(tvec, &sb->x);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
|
|
|
|
|
copy_v2_fl2(tvec, 0.0f, sb->h);
|
|
|
|
|
mul_m2v2(mat, tvec);
|
|
|
|
|
add_v2_v2(tvec, &sb->x);
|
|
|
|
|
glVertex3fv(tvec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
set_inverted_drawing(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw a sphere for use as an empty drawtype */
|
2012-03-25 23:54:33 +00:00
|
|
|
static void draw_empty_sphere(float size)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
static GLuint displist = 0;
|
2008-12-21 10:52:57 +00:00
|
|
|
|
|
|
|
|
if (displist == 0) {
|
2015-03-30 00:51:00 -04:00
|
|
|
GLUquadricObj *qobj;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
displist = glGenLists(1);
|
2010-09-08 02:55:48 +00:00
|
|
|
glNewList(displist, GL_COMPILE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-21 10:52:57 +00:00
|
|
|
glPushMatrix();
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
qobj = gluNewQuadric();
|
|
|
|
|
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
|
2008-12-21 10:52:57 +00:00
|
|
|
gluDisk(qobj, 0.0, 1, 16, 1);
|
|
|
|
|
|
|
|
|
|
glRotatef(90, 0, 1, 0);
|
|
|
|
|
gluDisk(qobj, 0.0, 1, 16, 1);
|
|
|
|
|
|
|
|
|
|
glRotatef(90, 1, 0, 0);
|
|
|
|
|
gluDisk(qobj, 0.0, 1, 16, 1);
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
gluDeleteQuadric(qobj);
|
2008-12-21 10:52:57 +00:00
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
glEndList();
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-21 10:52:57 +00:00
|
|
|
glScalef(size, size, size);
|
2010-09-08 02:55:48 +00:00
|
|
|
glCallList(displist);
|
2012-03-25 23:54:33 +00:00
|
|
|
glScalef(1.0f / size, 1.0f / size, 1.0f / size);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw a cone for use as an empty drawtype */
|
2012-03-25 23:54:33 +00:00
|
|
|
static void draw_empty_cone(float size)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2015-03-30 02:53:39 -04:00
|
|
|
const float radius = size;
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
GLUquadricObj *qobj = gluNewQuadric();
|
|
|
|
|
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
|
2011-03-27 15:57:27 +00:00
|
|
|
glScalef(radius, size * 2.0f, radius);
|
2012-04-11 08:15:13 +00:00
|
|
|
glRotatef(-90.0, 1.0, 0.0, 0.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
|
|
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
gluDeleteQuadric(qobj);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
static void drawspiral(const float cent[3], float rad, float tmat[4][4], int start)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
float vec[3], vx[3], vy[3];
|
2015-03-30 00:51:00 -04:00
|
|
|
const float tot_inv = 1.0f / (float)CIRCLE_RESOL;
|
2011-09-16 06:56:50 +00:00
|
|
|
int a;
|
2013-03-24 12:13:13 +00:00
|
|
|
bool inverse = false;
|
2011-09-22 18:42:16 +00:00
|
|
|
float x, y, fac;
|
2011-09-16 06:56:50 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
if (start < 0) {
|
2013-03-24 12:13:13 +00:00
|
|
|
inverse = true;
|
2012-03-25 23:54:33 +00:00
|
|
|
start = -start;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-01 11:00:36 +00:00
|
|
|
mul_v3_v3fl(vx, tmat[0], rad);
|
|
|
|
|
mul_v3_v3fl(vy, tmat[1], rad);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2011-09-22 18:42:16 +00:00
|
|
|
glBegin(GL_LINE_STRIP);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (inverse == 0) {
|
2011-09-22 18:42:16 +00:00
|
|
|
copy_v3_v3(vec, cent);
|
|
|
|
|
glVertex3fv(vec);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = 0; a < CIRCLE_RESOL; a++) {
|
|
|
|
|
if (a + start >= CIRCLE_RESOL)
|
|
|
|
|
start = -a + 1;
|
2011-09-22 18:42:16 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
fac = (float)a * tot_inv;
|
|
|
|
|
x = sinval[a + start] * fac;
|
|
|
|
|
y = cosval[a + start] * fac;
|
2011-09-22 18:42:16 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
|
|
|
|
|
vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
|
|
|
|
|
vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
|
2011-09-22 18:42:16 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
fac = (float)(CIRCLE_RESOL - 1) * tot_inv;
|
|
|
|
|
x = sinval[start] * fac;
|
|
|
|
|
y = cosval[start] * fac;
|
2011-09-22 18:42:16 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
|
|
|
|
|
vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
|
|
|
|
|
vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
|
2011-09-22 18:42:16 +00:00
|
|
|
|
|
|
|
|
glVertex3fv(vec);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (a = 0; a < CIRCLE_RESOL; a++) {
|
|
|
|
|
if (a + start >= CIRCLE_RESOL)
|
|
|
|
|
start = -a + 1;
|
2011-09-22 18:42:16 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
fac = (float)(-a + (CIRCLE_RESOL - 1)) * tot_inv;
|
|
|
|
|
x = sinval[a + start] * fac;
|
|
|
|
|
y = cosval[a + start] * fac;
|
2011-09-22 18:42:16 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0] = cent[0] + (x * vx[0] + y * vy[0]);
|
|
|
|
|
vec[1] = cent[1] + (x * vx[1] + y * vy[1]);
|
|
|
|
|
vec[2] = cent[2] + (x * vx[2] + y * vy[2]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glVertex3fv(vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-22 18:42:16 +00:00
|
|
|
|
|
|
|
|
glEnd();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-11 03:25:19 +00:00
|
|
|
/* draws a circle on x-z plane given the scaling of the circle, assuming that
|
2015-03-30 00:51:00 -04:00
|
|
|
* all required matrices have been set (used for drawing empties) */
|
2008-12-19 12:14:58 +00:00
|
|
|
static void drawcircle_size(float size)
|
|
|
|
|
{
|
|
|
|
|
glBegin(GL_LINE_LOOP);
|
2009-12-26 20:23:13 +00:00
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* coordinates are: cos(degrees * 11.25) = x, sin(degrees * 11.25) = y, 0.0f = z */
|
2015-12-16 01:24:15 -05:00
|
|
|
for (short degrees = 0; degrees < CIRCLE_RESOL; degrees++) {
|
|
|
|
|
float x = cosval[degrees];
|
|
|
|
|
float y = sinval[degrees];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(x * size, 0.0f, y * size);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-23 11:24:48 +00:00
|
|
|
/* needs fixing if non-identity matrix used */
|
2012-12-11 14:29:01 +00:00
|
|
|
static void drawtube(const float vec[3], float radius, float height, float tmat[4][4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
float cur[3];
|
|
|
|
|
drawcircball(GL_LINE_LOOP, vec, radius, tmat);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(cur, vec);
|
|
|
|
|
cur[2] += height;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
drawcircball(GL_LINE_LOOP, cur, radius, tmat);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(vec[0] + radius, vec[1], vec[2]);
|
|
|
|
|
glVertex3f(cur[0] + radius, cur[1], cur[2]);
|
|
|
|
|
glVertex3f(vec[0] - radius, vec[1], vec[2]);
|
|
|
|
|
glVertex3f(cur[0] - radius, cur[1], cur[2]);
|
|
|
|
|
glVertex3f(vec[0], vec[1] + radius, vec[2]);
|
|
|
|
|
glVertex3f(cur[0], cur[1] + radius, cur[2]);
|
|
|
|
|
glVertex3f(vec[0], vec[1] - radius, vec[2]);
|
|
|
|
|
glVertex3f(cur[0], cur[1] - radius, cur[2]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
2013-01-23 11:24:48 +00:00
|
|
|
|
|
|
|
|
/* needs fixing if non-identity matrix used */
|
2012-12-11 14:29:01 +00:00
|
|
|
static void drawcone(const float vec[3], float radius, float height, float tmat[4][4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
float cur[3];
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(cur, vec);
|
|
|
|
|
cur[2] += height;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
drawcircball(GL_LINE_LOOP, cur, radius, tmat);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
glVertex3f(vec[0], vec[1], vec[2]);
|
|
|
|
|
glVertex3f(cur[0] + radius, cur[1], cur[2]);
|
|
|
|
|
glVertex3f(vec[0], vec[1], vec[2]);
|
|
|
|
|
glVertex3f(cur[0] - radius, cur[1], cur[2]);
|
|
|
|
|
glVertex3f(vec[0], vec[1], vec[2]);
|
|
|
|
|
glVertex3f(cur[0], cur[1] + radius, cur[2]);
|
|
|
|
|
glVertex3f(vec[0], vec[1], vec[2]);
|
|
|
|
|
glVertex3f(cur[0], cur[1] - radius, cur[2]);
|
2008-12-19 12:14:58 +00:00
|
|
|
glEnd();
|
|
|
|
|
}
|
2013-01-23 11:24:48 +00:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/* return true if nothing was drawn */
|
|
|
|
|
static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|
|
|
|
const char dt, const short dflag, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
2008-12-19 12:14:58 +00:00
|
|
|
MetaElem *ml;
|
2010-02-01 15:32:55 +00:00
|
|
|
float imat[4][4];
|
2012-03-25 23:54:33 +00:00
|
|
|
int code = 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
MetaBall *mb = ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (mb->editelems) {
|
2012-06-06 18:00:08 +00:00
|
|
|
if ((G.f & G_PICKSEL) == 0) {
|
2012-10-06 12:04:09 +00:00
|
|
|
unsigned char wire_col[4];
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_col);
|
2012-06-06 18:00:08 +00:00
|
|
|
glColor3ubv(wire_col);
|
|
|
|
|
|
2012-09-25 13:31:46 +00:00
|
|
|
drawDispList(scene, v3d, rv3d, base, dt, dflag, wire_col);
|
2012-06-06 18:00:08 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
ml = mb->editelems->first;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-06-06 18:00:08 +00:00
|
|
|
if ((base->flag & OB_FROMDUPLI) == 0) {
|
2012-09-25 13:31:46 +00:00
|
|
|
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
2012-06-06 18:00:08 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
ml = mb->elems.first;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
if (ml == NULL) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return true;
|
2012-08-16 18:37:30 +00:00
|
|
|
}
|
2010-07-06 17:10:02 +00:00
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
if (v3d->flag2 & V3D_RENDER_OVERRIDE) {
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
invert_m4_m4(imat, rv3d->viewmatob);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(imat[0]);
|
|
|
|
|
normalize_v3(imat[1]);
|
2012-08-16 18:37:30 +00:00
|
|
|
|
|
|
|
|
if (mb->editelems == NULL) {
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
while (ml) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw radius */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (mb->editelems) {
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0);
|
|
|
|
|
else cpack(0x3030A0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (G.f & G_PICKSEL) {
|
2012-03-25 23:54:33 +00:00
|
|
|
ml->selcol1 = code;
|
2014-07-23 15:24:07 +02:00
|
|
|
GPU_select_load_id(code++);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad, imat);
|
|
|
|
|
|
|
|
|
|
/* draw stiffness */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (mb->editelems) {
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0);
|
|
|
|
|
else cpack(0x30A030);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (G.f & G_PICKSEL) {
|
2012-03-25 23:54:33 +00:00
|
|
|
ml->selcol2 = code;
|
2014-07-23 15:24:07 +02:00
|
|
|
GPU_select_load_id(code++);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad * atanf(ml->s) / (float)M_PI_2, imat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
ml = ml->next;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
return false;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
static void draw_forcefield(Object *ob, RegionView3D *rv3d,
|
|
|
|
|
const short dflag, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
PartDeflect *pd = ob->pd;
|
2008-12-19 12:14:58 +00:00
|
|
|
float imat[4][4], tmat[4][4];
|
2012-03-25 23:54:33 +00:00
|
|
|
float vec[3] = {0.0, 0.0, 0.0};
|
2008-12-19 12:14:58 +00:00
|
|
|
/* scale size of circle etc with the empty drawsize */
|
2015-03-30 02:53:39 -04:00
|
|
|
const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* calculus here, is reused in PFIELD_FORCE */
|
2010-02-01 15:32:55 +00:00
|
|
|
invert_m4_m4(imat, rv3d->viewmatob);
|
2015-03-30 00:51:00 -04:00
|
|
|
#if 0
|
|
|
|
|
normalize_v3(imat[0]); /* we don't do this because field doesnt scale either... apart from wind! */
|
|
|
|
|
normalize_v3(imat[1]);
|
|
|
|
|
#endif
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
if (pd->forcefield == PFIELD_WIND) {
|
2015-03-30 01:25:34 -04:00
|
|
|
float force_val = pd->f_strength;
|
2012-08-16 18:37:30 +00:00
|
|
|
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unit_m4(tmat);
|
2011-03-27 15:57:27 +00:00
|
|
|
force_val *= 0.1f;
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size, tmat);
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 0.5f * force_val;
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size, tmat);
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 1.0f * force_val;
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size, tmat);
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[2] = 1.5f * force_val;
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size, tmat);
|
2011-03-27 15:57:27 +00:00
|
|
|
vec[2] = 0.0f; /* reset vec for max dist circle */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (pd->forcefield == PFIELD_FORCE) {
|
2015-03-30 01:25:34 -04:00
|
|
|
float ffall_val = pd->f_power;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f);
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size, imat);
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val));
|
2011-03-27 15:57:27 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat);
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val));
|
2012-03-25 23:54:33 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, size * 2.0f, imat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else if (pd->forcefield == PFIELD_VORTEX) {
|
2015-03-30 01:25:34 -04:00
|
|
|
float force_val = pd->f_strength;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.7f);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
if (force_val < 0) {
|
2011-03-27 15:57:27 +00:00
|
|
|
drawspiral(vec, size, tmat, 1);
|
|
|
|
|
drawspiral(vec, size, tmat, 16);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-03-27 15:57:27 +00:00
|
|
|
drawspiral(vec, size, tmat, -1);
|
|
|
|
|
drawspiral(vec, size, tmat, -16);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (pd->forcefield == PFIELD_GUIDE && ob->type == OB_CURVE) {
|
|
|
|
|
Curve *cu = ob->data;
|
2013-08-19 09:25:24 +00:00
|
|
|
if ((cu->flag & CU_PATH) && ob->curve_cache->path && ob->curve_cache->path->data) {
|
2015-03-30 01:25:34 -04:00
|
|
|
float guidevec1[4], guidevec2[3];
|
|
|
|
|
float mindist = pd->f_strength;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-08-16 18:37:30 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-30 01:25:34 -04:00
|
|
|
/* path end */
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(3);
|
2010-04-21 11:59:47 +00:00
|
|
|
where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
|
|
|
|
|
|
2015-03-30 01:25:34 -04:00
|
|
|
/* path beginning */
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(0);
|
2010-04-21 11:59:47 +00:00
|
|
|
where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
copy_v3_v3(vec, guidevec1); /* max center */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setlinestyle(3);
|
2012-08-16 18:37:30 +00:00
|
|
|
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pd->falloff == PFIELD_FALL_SPHERE) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* as last, guide curve alters it */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pd->flag & PFIELD_USEMAX)
|
2012-03-18 06:01:33 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, pd->maxdist, imat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (pd->flag & PFIELD_USEMIN)
|
2008-12-19 12:14:58 +00:00
|
|
|
drawcircball(GL_LINE_LOOP, vec, pd->mindist, imat);
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (pd->falloff == PFIELD_FALL_TUBE) {
|
|
|
|
|
float radius, distance;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0] = vec[1] = 0.0f;
|
|
|
|
|
radius = (pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f;
|
|
|
|
|
distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f;
|
|
|
|
|
vec[2] = distance;
|
|
|
|
|
distance = (pd->flag & PFIELD_POSZ) ? -distance : -2.0f * distance;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR))
|
|
|
|
|
drawtube(vec, radius, distance, tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
radius = (pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f;
|
|
|
|
|
distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f;
|
|
|
|
|
vec[2] = distance;
|
|
|
|
|
distance = (pd->flag & PFIELD_POSZ) ? -distance : -2.0f * distance;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR))
|
|
|
|
|
drawtube(vec, radius, distance, tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (pd->falloff == PFIELD_FALL_CONE) {
|
|
|
|
|
float radius, distance;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
radius = DEG2RADF((pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f);
|
|
|
|
|
distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) {
|
|
|
|
|
drawcone(vec, distance * sinf(radius), distance * cosf(radius), tmat);
|
|
|
|
|
if ((pd->flag & PFIELD_POSZ) == 0)
|
|
|
|
|
drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
radius = DEG2RADF((pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f);
|
|
|
|
|
distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) {
|
|
|
|
|
drawcone(vec, distance * sinf(radius), distance * cosf(radius), tmat);
|
|
|
|
|
if ((pd->flag & PFIELD_POSZ) == 0)
|
2011-03-27 15:57:27 +00:00
|
|
|
drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
static void draw_box(float vec[8][3], bool solid)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2015-04-18 12:28:19 +02:00
|
|
|
if (!solid) {
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
|
glVertex3fv(vec[0]); glVertex3fv(vec[1]); glVertex3fv(vec[2]); glVertex3fv(vec[3]);
|
|
|
|
|
glVertex3fv(vec[0]); glVertex3fv(vec[4]); glVertex3fv(vec[5]); glVertex3fv(vec[6]);
|
|
|
|
|
glVertex3fv(vec[7]); glVertex3fv(vec[4]);
|
|
|
|
|
glEnd();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(vec[1]); glVertex3fv(vec[5]);
|
|
|
|
|
glVertex3fv(vec[2]); glVertex3fv(vec[6]);
|
|
|
|
|
glVertex3fv(vec[3]); glVertex3fv(vec[7]);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
glVertex3fv(vec[0]); glVertex3fv(vec[1]); glVertex3fv(vec[2]); glVertex3fv(vec[3]);
|
|
|
|
|
glVertex3fv(vec[7]); glVertex3fv(vec[6]); glVertex3fv(vec[5]); glVertex3fv(vec[4]);
|
|
|
|
|
glVertex3fv(vec[4]); glVertex3fv(vec[5]); glVertex3fv(vec[1]); glVertex3fv(vec[0]);
|
|
|
|
|
glVertex3fv(vec[3]); glVertex3fv(vec[2]); glVertex3fv(vec[6]); glVertex3fv(vec[7]);
|
|
|
|
|
glVertex3fv(vec[3]); glVertex3fv(vec[7]); glVertex3fv(vec[4]); glVertex3fv(vec[0]);
|
|
|
|
|
glVertex3fv(vec[1]); glVertex3fv(vec[5]); glVertex3fv(vec[6]); glVertex3fv(vec[2]);
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-25 19:01:42 +01:00
|
|
|
static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
float size[3], cent[3];
|
2012-03-18 06:01:33 +00:00
|
|
|
GLUquadricObj *qobj = gluNewQuadric();
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-08-11 13:25:25 +10:00
|
|
|
BKE_boundbox_calc_size_aabb(bb, size);
|
2012-03-25 23:54:33 +00:00
|
|
|
|
2013-12-25 19:01:42 +01:00
|
|
|
if (around_origin) {
|
|
|
|
|
zero_v3(cent);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2014-08-11 13:25:25 +10:00
|
|
|
BKE_boundbox_calc_center_aabb(bb, cent);
|
2013-12-25 19:01:42 +01:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glPushMatrix();
|
2012-03-25 23:54:33 +00:00
|
|
|
if (type == OB_BOUND_SPHERE) {
|
2013-10-25 02:20:23 +00:00
|
|
|
float scale = MAX3(size[0], size[1], size[2]);
|
2015-09-20 18:11:25 +02:00
|
|
|
glTranslate3fv(cent);
|
2013-10-25 02:20:23 +00:00
|
|
|
glScalef(scale, scale, scale);
|
2008-12-19 12:14:58 +00:00
|
|
|
gluSphere(qobj, 1.0, 8, 5);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (type == OB_BOUND_CYLINDER) {
|
2008-12-19 12:14:58 +00:00
|
|
|
float radius = size[0] > size[1] ? size[0] : size[1];
|
2012-03-25 23:54:33 +00:00
|
|
|
glTranslatef(cent[0], cent[1], cent[2] - size[2]);
|
2011-03-27 15:57:27 +00:00
|
|
|
glScalef(radius, radius, 2.0f * size[2]);
|
2008-12-19 12:14:58 +00:00
|
|
|
gluCylinder(qobj, 1.0, 1.0, 1.0, 8, 1);
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (type == OB_BOUND_CONE) {
|
2008-12-19 12:14:58 +00:00
|
|
|
float radius = size[0] > size[1] ? size[0] : size[1];
|
2012-03-25 23:54:33 +00:00
|
|
|
glTranslatef(cent[0], cent[1], cent[2] - size[2]);
|
2011-11-28 16:25:42 +00:00
|
|
|
glScalef(radius, radius, 2.0f * size[2]);
|
2008-12-19 12:14:58 +00:00
|
|
|
gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1);
|
|
|
|
|
}
|
2013-03-18 20:32:30 +00:00
|
|
|
else if (type == OB_BOUND_CAPSULE) {
|
|
|
|
|
float radius = size[0] > size[1] ? size[0] : size[1];
|
|
|
|
|
float length = size[2] > radius ? 2.0f * (size[2] - radius) : 0.0f;
|
|
|
|
|
glTranslatef(cent[0], cent[1], cent[2] - length * 0.5f);
|
|
|
|
|
gluCylinder(qobj, radius, radius, length, 8, 1);
|
|
|
|
|
gluSphere(qobj, radius, 8, 4);
|
|
|
|
|
glTranslatef(0.0, 0.0, length);
|
|
|
|
|
gluSphere(qobj, radius, 8, 4);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
glPopMatrix();
|
|
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
gluDeleteQuadric(qobj);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-13 16:33:18 +06:00
|
|
|
static void draw_bounding_volume(Object *ob, char type)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2013-06-09 21:29:20 +00:00
|
|
|
BoundBox bb_local;
|
2012-03-25 23:54:33 +00:00
|
|
|
BoundBox *bb = NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2012-05-05 21:28:12 +00:00
|
|
|
bb = BKE_mesh_boundbox_get(ob);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
2013-08-21 07:40:19 +00:00
|
|
|
bb = BKE_curve_boundbox_get(ob);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ob->type == OB_MBALL) {
|
2012-05-07 06:38:41 +00:00
|
|
|
if (BKE_mball_is_basis(ob)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
bb = ob->bb;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-22 13:27:24 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2012-05-05 16:03:57 +00:00
|
|
|
bb = BKE_armature_boundbox_get(ob);
|
2012-03-22 13:27:24 +00:00
|
|
|
}
|
2015-08-13 18:12:08 +02:00
|
|
|
else if (ob->type == OB_LATTICE) {
|
|
|
|
|
bb = BKE_lattice_boundbox_get(ob);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
else {
|
2013-06-09 21:29:20 +00:00
|
|
|
const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f};
|
|
|
|
|
bb = &bb_local;
|
|
|
|
|
BKE_boundbox_init_from_minmax(bb, min, max);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-25 19:01:42 +01:00
|
|
|
if (bb == NULL)
|
|
|
|
|
return;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-12-25 19:01:42 +01:00
|
|
|
if (ob->gameflag & OB_BOUNDS) { /* bounds need to be drawn around origin for game engine */
|
|
|
|
|
|
|
|
|
|
if (type == OB_BOUND_BOX) {
|
2013-12-25 19:25:46 +01:00
|
|
|
float vec[8][3], size[3];
|
|
|
|
|
|
2014-08-11 13:25:25 +10:00
|
|
|
BKE_boundbox_calc_size_aabb(bb, size);
|
2013-12-25 19:01:42 +01:00
|
|
|
|
|
|
|
|
vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0];
|
|
|
|
|
vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0];
|
|
|
|
|
vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1];
|
|
|
|
|
vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1];
|
|
|
|
|
vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2];
|
|
|
|
|
vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2];
|
|
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
draw_box(vec, false);
|
2013-12-25 19:01:42 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
draw_bb_quadric(bb, type, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (type == OB_BOUND_BOX)
|
2015-04-18 12:28:19 +02:00
|
|
|
draw_box(bb->vec, false);
|
2013-12-25 19:01:42 +01:00
|
|
|
else
|
|
|
|
|
draw_bb_quadric(bb, type, false);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void drawtexspace(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
float vec[8][3], loc[3], size[3];
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2012-05-05 21:28:12 +00:00
|
|
|
BKE_mesh_texspace_get(ob->data, loc, NULL, size);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
2013-08-21 07:40:19 +00:00
|
|
|
BKE_curve_texspace_get(ob->data, loc, NULL, size);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ob->type == OB_MBALL) {
|
|
|
|
|
MetaBall *mb = ob->data;
|
2010-08-01 11:00:36 +00:00
|
|
|
copy_v3_v3(size, mb->size);
|
|
|
|
|
copy_v3_v3(loc, mb->loc);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = loc[0] - size[0];
|
|
|
|
|
vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = loc[0] + size[0];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = loc[1] - size[1];
|
|
|
|
|
vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = loc[1] + size[1];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = loc[2] - size[2];
|
|
|
|
|
vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = loc[2] + size[2];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
setlinestyle(2);
|
|
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
draw_box(vec, false);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draws wire outline */
|
2012-06-06 18:00:08 +00:00
|
|
|
static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
|
|
|
|
|
const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
Object *ob = base->object;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-26 02:14:07 +00:00
|
|
|
glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f);
|
2008-12-19 12:14:58 +00:00
|
|
|
glDepthMask(0);
|
|
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
|
2013-03-24 12:13:13 +00:00
|
|
|
bool has_faces = false;
|
2010-03-05 16:47:52 +00:00
|
|
|
|
2014-02-18 00:11:27 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
ensure_curve_cache(scene, ob);
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-12-16 01:24:15 -05:00
|
|
|
DerivedMesh *dm = ob->derivedFinal;
|
2014-12-09 14:37:47 +01:00
|
|
|
if (dm) {
|
|
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-04 11:07:42 +00:00
|
|
|
if (dm) {
|
2015-08-01 14:42:14 +10:00
|
|
|
has_faces = (dm->getNumPolys(dm) != 0);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-08-19 09:25:24 +00:00
|
|
|
has_faces = BKE_displist_has_faces(&ob->curve_cache->disp);
|
2010-04-04 11:07:42 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-20 12:17:44 +11:00
|
|
|
if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
2010-03-05 16:47:52 +00:00
|
|
|
if (dm) {
|
|
|
|
|
draw_mesh_object_outline(v3d, ob, dm);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2014-06-04 08:36:22 +10:00
|
|
|
drawDispListwire(&ob->curve_cache->disp, ob->type);
|
2010-03-05 16:47:52 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ob->type == OB_MBALL) {
|
2012-05-07 06:38:41 +00:00
|
|
|
if (BKE_mball_is_basis(ob)) {
|
2014-06-04 08:36:22 +10:00
|
|
|
if ((base->flag & OB_FROMDUPLI) == 0) {
|
|
|
|
|
drawDispListwire(&ob->curve_cache->disp, ob->type);
|
|
|
|
|
}
|
2010-11-18 04:26:50 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(ob->mode & OB_MODE_POSE && base == scene->basact))
|
2013-03-24 12:13:13 +00:00
|
|
|
draw_armature(scene, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glLineWidth(1.0);
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-11 15:41:20 +10:00
|
|
|
static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)) {
|
2012-08-16 17:42:06 +00:00
|
|
|
|
|
|
|
|
if (scene->obedit == ob) {
|
2013-06-08 21:58:00 +00:00
|
|
|
UI_ThemeColor(TH_WIRE_EDIT);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-08-16 17:42:06 +00:00
|
|
|
glColor3ubv(ob_wire_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-07-08 20:36:00 +00:00
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 1.0);
|
2012-08-16 17:42:06 +00:00
|
|
|
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
|
|
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
|
2014-03-20 12:17:44 +11:00
|
|
|
if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
2012-08-16 17:42:06 +00:00
|
|
|
|
|
|
|
|
if (ob->derivedFinal) {
|
|
|
|
|
drawCurveDMWired(ob);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2014-06-04 08:36:22 +10:00
|
|
|
drawDispListwire(&ob->curve_cache->disp, ob->type);
|
2012-08-16 17:42:06 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2012-08-16 17:42:06 +00:00
|
|
|
}
|
|
|
|
|
else if (ob->type == OB_MBALL) {
|
|
|
|
|
if (BKE_mball_is_basis(ob)) {
|
2014-06-04 08:36:22 +10:00
|
|
|
drawDispListwire(&ob->curve_cache->disp, ob->type);
|
2010-03-05 16:47:52 +00:00
|
|
|
}
|
2010-11-18 04:26:50 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-08-16 17:42:06 +00:00
|
|
|
glDepthMask(1);
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
2012-08-16 17:42:06 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* should be called in view space */
|
|
|
|
|
static void draw_hooks(Object *ob)
|
|
|
|
|
{
|
2015-12-16 01:24:15 -05:00
|
|
|
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (md->type == eModifierType_Hook) {
|
|
|
|
|
HookModifierData *hmd = (HookModifierData *) md;
|
2015-12-16 01:24:15 -05:00
|
|
|
float vec[3];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_m4v3(vec, ob->obmat, hmd->cent);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (hmd->object) {
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(hmd->object->obmat[3]);
|
|
|
|
|
glVertex3fv(vec);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glPointSize(3.0);
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
bglVertex3fv(vec);
|
|
|
|
|
bglEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-11 15:41:20 +10:00
|
|
|
static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data,
|
|
|
|
|
const short dflag, const unsigned char ob_wire_col[4])
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-02-28 13:03:56 +00:00
|
|
|
const char *axis_str[3] = {"px", "py", "pz"};
|
2008-12-19 12:14:58 +00:00
|
|
|
float mat[4][4];
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
eul_to_mat4(mat, &data->axX);
|
|
|
|
|
glLineWidth(4.0f);
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(2);
|
2015-12-16 01:24:15 -05:00
|
|
|
for (int axis = 0; axis < 3; axis++) {
|
2012-03-25 23:54:33 +00:00
|
|
|
float dir[3] = {0, 0, 0};
|
2010-11-03 06:31:53 +00:00
|
|
|
float v[3];
|
|
|
|
|
|
|
|
|
|
copy_v3_v3(v, &data->pivX);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-25 13:55:16 +00:00
|
|
|
dir[axis] = 1.0f;
|
2009-05-18 16:42:34 +00:00
|
|
|
glBegin(GL_LINES);
|
2012-03-25 23:54:33 +00:00
|
|
|
mul_m4_v3(mat, dir);
|
2010-07-31 10:58:10 +00:00
|
|
|
add_v3_v3(v, dir);
|
2010-11-03 06:31:53 +00:00
|
|
|
glVertex3fv(&data->pivX);
|
2012-03-18 06:01:33 +00:00
|
|
|
glVertex3fv(v);
|
2009-05-18 16:42:34 +00:00
|
|
|
glEnd();
|
2012-02-28 13:03:56 +00:00
|
|
|
|
2012-07-25 13:55:16 +00:00
|
|
|
/* when const color is set wirecolor is NULL - we could get the current color but
|
|
|
|
|
* with selection and group instancing its not needed to draw the text */
|
|
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(v, axis_str[axis], 2, 0, V3D_CACHE_TEXT_ASCII, ob_wire_col);
|
2012-07-25 13:55:16 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
glLineWidth(1.0f);
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-20 05:50:22 +00:00
|
|
|
static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_wire_col[4])
|
2012-06-06 18:00:08 +00:00
|
|
|
{
|
|
|
|
|
Object *ob = base->object;
|
|
|
|
|
int colindex = 0;
|
2013-06-08 21:58:00 +00:00
|
|
|
const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
|
2012-06-06 18:00:08 +00:00
|
|
|
/* confusing logic here, there are 2 methods of setting the color
|
|
|
|
|
* 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
|
|
|
|
|
*
|
|
|
|
|
* note: no theme yet for 'colindex' */
|
2013-06-08 21:58:00 +00:00
|
|
|
int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
|
2012-06-06 18:00:08 +00:00
|
|
|
int theme_shade = 0;
|
|
|
|
|
|
|
|
|
|
if ((scene->obedit == NULL) &&
|
|
|
|
|
(G.moving & G_TRANSFORM_OBJ) &&
|
|
|
|
|
(base->flag & (SELECT + BA_WAS_SEL)))
|
|
|
|
|
{
|
|
|
|
|
theme_id = TH_TRANSFORM;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Sets the 'colindex' */
|
|
|
|
|
if (ob->id.lib) {
|
2013-04-20 05:50:22 +00:00
|
|
|
colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 2 : 1;
|
2012-06-06 18:00:08 +00:00
|
|
|
}
|
|
|
|
|
/* Sets the 'theme_id' or fallback to wire */
|
|
|
|
|
else {
|
|
|
|
|
if (ob->flag & OB_FROMGROUP) {
|
|
|
|
|
if (base->flag & (SELECT + BA_WAS_SEL)) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* uses darker active color for non-active + selected */
|
2012-06-06 18:00:08 +00:00
|
|
|
theme_id = TH_GROUP_ACTIVE;
|
|
|
|
|
|
|
|
|
|
if (scene->basact != base) {
|
|
|
|
|
theme_shade = -16;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
theme_id = TH_GROUP;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (base->flag & (SELECT + BA_WAS_SEL)) {
|
|
|
|
|
theme_id = scene->basact == base ? TH_ACTIVE : TH_SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (ob->type == OB_LAMP) theme_id = TH_LAMP;
|
|
|
|
|
else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
|
|
|
|
|
else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
|
|
|
|
|
else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
|
|
|
|
|
/* fallback to TH_WIRE */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* finally set the color */
|
|
|
|
|
if (colindex == 0) {
|
|
|
|
|
if (theme_shade == 0) UI_GetThemeColor3ubv(theme_id, r_ob_wire_col);
|
|
|
|
|
else UI_GetThemeColorShade3ubv(theme_id, theme_shade, r_ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cpack_cpy_3ub(r_ob_wire_col, colortab[colindex]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no reason to use this but some functions take col[4] */
|
|
|
|
|
r_ob_wire_col[3] = 255;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-16 18:32:57 +11:00
|
|
|
static void draw_object_matcap_check(View3D *v3d, Object *ob)
|
2013-01-22 11:18:41 +00:00
|
|
|
{
|
|
|
|
|
/* fixed rule, active object draws as matcap */
|
2014-01-16 18:32:57 +11:00
|
|
|
BLI_assert((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) == 0);
|
2014-01-16 22:27:25 +01:00
|
|
|
(void)ob;
|
2014-01-16 18:32:57 +11:00
|
|
|
|
|
|
|
|
if (v3d->defmaterial == NULL) {
|
|
|
|
|
extern Material defmaterial;
|
|
|
|
|
|
|
|
|
|
v3d->defmaterial = MEM_mallocN(sizeof(Material), "matcap material");
|
|
|
|
|
*(v3d->defmaterial) = defmaterial;
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&v3d->defmaterial->gpumaterial);
|
2014-01-16 18:32:57 +11:00
|
|
|
v3d->defmaterial->preview = NULL;
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
2014-01-16 18:32:57 +11:00
|
|
|
/* first time users */
|
2015-03-23 12:00:34 +01:00
|
|
|
if (v3d->matcap_icon < ICON_MATCAP_01 ||
|
|
|
|
|
v3d->matcap_icon > ICON_MATCAP_24)
|
|
|
|
|
{
|
2014-01-16 18:32:57 +11:00
|
|
|
v3d->matcap_icon = ICON_MATCAP_01;
|
2015-03-23 12:00:34 +01:00
|
|
|
}
|
2014-01-16 18:32:57 +11:00
|
|
|
|
|
|
|
|
if (v3d->defmaterial->preview == NULL)
|
|
|
|
|
v3d->defmaterial->preview = UI_icon_to_preview(v3d->matcap_icon);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2014-01-16 18:32:57 +11:00
|
|
|
/* signal to all material checks, gets cleared below */
|
|
|
|
|
v3d->flag2 |= V3D_SHOW_SOLID_MATCAP;
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-25 19:05:55 +01:00
|
|
|
static void draw_rigidbody_shape(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
BoundBox *bb = NULL;
|
|
|
|
|
float size[3], vec[8][3];
|
|
|
|
|
|
|
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
|
bb = BKE_mesh_boundbox_get(ob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bb == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (ob->rigidbody_object->shape) {
|
|
|
|
|
case RB_SHAPE_BOX:
|
2014-08-11 13:25:25 +10:00
|
|
|
BKE_boundbox_calc_size_aabb(bb, size);
|
2013-12-25 19:05:55 +01:00
|
|
|
|
|
|
|
|
vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0];
|
|
|
|
|
vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0];
|
|
|
|
|
vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1];
|
|
|
|
|
vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1];
|
|
|
|
|
vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2];
|
|
|
|
|
vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2];
|
|
|
|
|
|
2015-04-18 12:28:19 +02:00
|
|
|
draw_box(vec, false);
|
2013-12-25 19:05:55 +01:00
|
|
|
break;
|
|
|
|
|
case RB_SHAPE_SPHERE:
|
|
|
|
|
draw_bb_quadric(bb, OB_BOUND_SPHERE, true);
|
|
|
|
|
break;
|
|
|
|
|
case RB_SHAPE_CONE:
|
|
|
|
|
draw_bb_quadric(bb, OB_BOUND_CONE, true);
|
|
|
|
|
break;
|
|
|
|
|
case RB_SHAPE_CYLINDER:
|
|
|
|
|
draw_bb_quadric(bb, OB_BOUND_CYLINDER, true);
|
|
|
|
|
break;
|
|
|
|
|
case RB_SHAPE_CAPSULE:
|
|
|
|
|
draw_bb_quadric(bb, OB_BOUND_CAPSULE, true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-16 16:07:00 +00:00
|
|
|
/**
|
|
|
|
|
* main object drawing function, draws in selection
|
|
|
|
|
* \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
|
|
|
|
|
*/
|
2012-06-10 10:15:49 +00:00
|
|
|
void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2009-07-30 15:00:26 +00:00
|
|
|
ModifierData *md = NULL;
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *ob = base->object;
|
2008-12-19 12:14:58 +00:00
|
|
|
Curve *cu;
|
2012-03-25 23:54:33 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
unsigned int col = 0;
|
2014-04-11 15:41:20 +10:00
|
|
|
unsigned char _ob_wire_col[4]; /* dont initialize this */
|
|
|
|
|
const unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */
|
2014-06-16 17:12:08 +10:00
|
|
|
bool zbufoff = false, is_paint = false, empty_object = false;
|
2013-03-29 04:01:52 +00:00
|
|
|
const bool is_obact = (ob == OBACT);
|
2013-10-21 15:44:09 +00:00
|
|
|
const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
|
2014-03-11 12:55:53 +06:00
|
|
|
const bool is_picking = (G.f & G_PICKSEL) != 0;
|
2014-07-17 23:49:08 +02:00
|
|
|
const bool has_particles = (ob->particlesystem.first != NULL);
|
2015-04-16 13:01:57 +02:00
|
|
|
bool skip_object = false; /* Draw particles but not their emitter object. */
|
|
|
|
|
SmokeModifierData *smd = NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob != scene->obedit) {
|
2014-06-29 13:24:50 +02:00
|
|
|
if (ob->restrictflag & OB_RESTRICT_VIEW)
|
2014-07-17 23:49:08 +02:00
|
|
|
return;
|
2014-06-29 13:24:50 +02:00
|
|
|
|
|
|
|
|
if (render_override) {
|
|
|
|
|
if (ob->restrictflag & OB_RESTRICT_RENDER)
|
2014-07-17 23:49:08 +02:00
|
|
|
return;
|
2014-06-29 13:24:50 +02:00
|
|
|
|
2014-08-06 04:56:18 +10:00
|
|
|
if (!has_particles && (ob->transflag & (OB_DUPLI & ~OB_DUPLIFRAMES)))
|
2014-07-17 23:49:08 +02:00
|
|
|
return;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-17 23:49:08 +02:00
|
|
|
if (has_particles) {
|
2013-10-21 15:44:09 +00:00
|
|
|
/* XXX particles are not safe for simultaneous threaded render */
|
|
|
|
|
if (G.is_rendering) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ob->mode == OB_MODE_OBJECT) {
|
|
|
|
|
ParticleSystem *psys;
|
|
|
|
|
|
2015-04-16 13:01:57 +02:00
|
|
|
skip_object = render_override;
|
2013-10-21 15:44:09 +00:00
|
|
|
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
|
|
|
|
|
/* Once we have found a psys which renders its emitter object, we are done. */
|
|
|
|
|
if (psys->part->draw & PART_DRAW_EMITTER) {
|
2015-04-16 13:01:57 +02:00
|
|
|
skip_object = false;
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-22 10:52:37 +00:00
|
|
|
|
2015-10-09 10:51:38 +02:00
|
|
|
if (((base->flag & OB_FROMDUPLI) == 0) &&
|
|
|
|
|
(md = modifiers_findByType(ob, eModifierType_Smoke)) &&
|
2015-10-17 01:01:57 +11:00
|
|
|
(modifier_isEnabled(scene, md, eModifierMode_Realtime)))
|
|
|
|
|
{
|
2015-04-16 13:01:57 +02:00
|
|
|
smd = (SmokeModifierData *)md;
|
|
|
|
|
|
|
|
|
|
if (smd->domain) {
|
|
|
|
|
if (!v3d->transp && (dflag & DRAW_PICKING) == 0) {
|
|
|
|
|
if (!v3d->xray && !(ob->dtx & OB_DRAWXRAY)) {
|
|
|
|
|
/* object has already been drawn so skip drawing it */
|
|
|
|
|
ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (v3d->xray) {
|
|
|
|
|
/* object has already been drawn so skip drawing it */
|
|
|
|
|
ED_view3d_after_add(&v3d->afterdraw_xraytransp, base, dflag);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* xray delay? */
|
2012-10-05 12:18:04 +00:00
|
|
|
if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* don't do xray in particle mode, need the z-buffer */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* xray and transp are set when it is drawing the 2nd/3rd pass */
|
2012-02-22 16:52:06 +00:00
|
|
|
if (!v3d->xray && !v3d->transp && (ob->dtx & OB_DRAWXRAY) && !(ob->dtx & OB_DRAWTRANSP)) {
|
2012-06-10 10:15:49 +00:00
|
|
|
ED_view3d_after_add(&v3d->afterdraw_xray, base, dflag);
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2013-04-03 05:16:15 +00:00
|
|
|
|
|
|
|
|
/* allow transp option for empty images */
|
|
|
|
|
if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
|
|
|
|
|
if (!v3d->xray && !v3d->transp && !(ob->dtx & OB_DRAWXRAY) && (ob->dtx & OB_DRAWTRANSP)) {
|
|
|
|
|
ED_view3d_after_add(&v3d->afterdraw_transp, base, dflag);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-16 17:12:08 +10:00
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2009-09-19 18:45:31 +00:00
|
|
|
/* no return after this point, otherwise leaks */
|
2014-06-16 17:12:08 +10:00
|
|
|
|
|
|
|
|
/* only once set now, will be removed too, should become a global standard */
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
2009-09-19 18:45:31 +00:00
|
|
|
view3d_cached_text_draw_begin();
|
2010-01-19 11:31:49 +00:00
|
|
|
|
|
|
|
|
/* draw motion paths (in view space) */
|
2013-10-21 15:44:09 +00:00
|
|
|
if (ob->mpath && !render_override) {
|
2012-03-25 23:54:33 +00:00
|
|
|
bAnimVizSettings *avs = &ob->avs;
|
2010-01-19 11:31:49 +00:00
|
|
|
|
|
|
|
|
/* setup drawing environment for paths */
|
2010-10-14 01:22:14 +00:00
|
|
|
draw_motion_paths_init(v3d, ar);
|
2010-01-19 11:31:49 +00:00
|
|
|
|
|
|
|
|
/* draw motion path for object */
|
2010-10-14 01:22:14 +00:00
|
|
|
draw_motion_path_instance(scene, ob, NULL, avs, ob->mpath);
|
2010-01-19 11:31:49 +00:00
|
|
|
|
|
|
|
|
/* cleanup after drawing */
|
2010-10-14 01:22:14 +00:00
|
|
|
draw_motion_paths_cleanup(v3d);
|
2010-01-19 11:31:49 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-10-11 19:57:56 +00:00
|
|
|
/* multiply view with object matrix.
|
|
|
|
|
* local viewmat and persmat, to calculate projections */
|
2011-06-09 03:56:32 +00:00
|
|
|
ED_view3d_init_mats_rv3d_gl(ob, rv3d);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* which wire color */
|
2012-06-10 10:15:49 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2011-09-12 01:43:20 +00:00
|
|
|
|
refactor ED_view3d_project_short & ED_view3d_project_short_noclip,
This is apart of a code cleanup to make ED_view3d_project_short/ED_view3d_project_int/ED_view3d_project_float interchangeable. Currently they work very differently in a way thats quite confusing (and cause of bugs in blender that remain uncorrected) - fixes coming.
There are also cases where ED_view3d_project_short is used, then the values are converted from shorts into int's after because ED_view3d_project_int() behaves differently, will unify behavior of these functions after this commit.
- rather then clip/noclip versions, pass flags (for bound-box clip, window clip).
- rather then store the invalid clip-value, return success (or error value clip_near, clip_bb, clip_win, overflow).
- remove local copies of project functions from drawobject.c: view3d_project_short_clip, view3d_project_short_noclip, view3d_project_short_clip_persmat.
add functions:
- ED_view3d_project_short_global() global space projection
- ED_view3d_project_short_object() object space projection.
- ED_view3d_project_short_ex() take perspective matrix and local space option as args.
- ED_view3d_project_base() - special function to set the Object 'Base' screen coords (sx, sy), since this is a common enough operation.
2012-10-04 16:46:15 +00:00
|
|
|
ED_view3d_project_base(ar, base);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-04-20 05:50:22 +00:00
|
|
|
draw_object_wire_color(scene, base, _ob_wire_col);
|
2012-06-07 08:02:48 +00:00
|
|
|
ob_wire_col = _ob_wire_col;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-06-06 18:00:08 +00:00
|
|
|
glColor3ubv(ob_wire_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* maximum drawtype */
|
2015-12-16 01:24:15 -05:00
|
|
|
char dt = v3d->drawtype;
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt == OB_RENDER) dt = OB_SOLID;
|
|
|
|
|
dt = MIN2(dt, ob->dt);
|
|
|
|
|
if (v3d->zbuf == 0 && dt > OB_WIRE) dt = OB_WIRE;
|
2015-12-16 01:24:15 -05:00
|
|
|
short dtx = 0;
|
2014-01-16 18:32:57 +11:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-05-25 09:51:53 +00:00
|
|
|
/* faceselect exception: also draw solid when (dt == wire), except in editmode */
|
2014-01-16 18:32:57 +11:00
|
|
|
if (is_obact) {
|
|
|
|
|
if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
|
|
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
|
if (dt < OB_SOLID) {
|
2015-02-12 18:54:41 +01:00
|
|
|
zbufoff = true;
|
2014-01-16 18:32:57 +11:00
|
|
|
dt = OB_SOLID;
|
|
|
|
|
}
|
2012-05-09 06:22:29 +00:00
|
|
|
|
2014-01-16 18:32:57 +11:00
|
|
|
if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
|
|
|
|
|
dt = OB_PAINT;
|
|
|
|
|
}
|
2013-08-26 14:58:16 +00:00
|
|
|
|
2014-03-21 15:15:43 +06:00
|
|
|
is_paint = true;
|
2014-01-16 18:32:57 +11:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-01-29 03:39:19 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* matcap check - only when not painting color */
|
2014-05-22 11:28:03 +10:00
|
|
|
if ((v3d->flag2 & V3D_SOLID_MATCAP) &&
|
|
|
|
|
(dt == OB_SOLID) &&
|
|
|
|
|
(is_paint == false && is_picking == false) &&
|
|
|
|
|
((v3d->flag2 & V3D_RENDER_SHADOW) == 0))
|
|
|
|
|
{
|
2014-01-29 03:39:19 +11:00
|
|
|
draw_object_matcap_check(v3d, ob);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2014-01-16 18:32:57 +11:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw-extra supported for boundbox drawmode too */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt >= OB_BOUNDBOX) {
|
|
|
|
|
dtx = ob->dtx;
|
2012-02-22 16:52:06 +00:00
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
2015-03-30 00:51:00 -04:00
|
|
|
/* the only 2 extra drawtypes alowed in editmode */
|
2012-03-25 23:54:33 +00:00
|
|
|
dtx = dtx & (OB_DRAWWIRE | OB_TEXSPACE);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-16 13:01:57 +02:00
|
|
|
if (!skip_object) {
|
2013-10-21 15:44:09 +00:00
|
|
|
/* draw outline for selected objects, mesh does itself */
|
|
|
|
|
if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
|
|
|
|
|
if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
|
|
|
|
|
if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
|
|
|
|
|
drawObjectSelect(scene, v3d, ar, base, ob_wire_col);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
|
2014-04-21 19:26:37 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
/* mesh draws wire itself */
|
|
|
|
|
dtx &= ~OB_DRAWWIRE;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_FONT:
|
|
|
|
|
cu = ob->data;
|
|
|
|
|
if (cu->editfont) {
|
2014-06-16 17:22:41 +10:00
|
|
|
draw_editfont(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
else if (dt == OB_BOUNDBOX) {
|
|
|
|
|
if ((render_override && v3d->drawtype >= OB_WIRE) == 0) {
|
2014-02-12 14:06:13 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
ensure_curve_cache(scene, base->object);
|
|
|
|
|
#endif
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2013-10-21 15:44:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-03-20 12:17:44 +11:00
|
|
|
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
2013-10-21 15:44:09 +00:00
|
|
|
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
2012-02-28 13:03:56 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_CURVE:
|
|
|
|
|
case OB_SURF:
|
|
|
|
|
cu = ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if (cu->editnurb) {
|
|
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
2014-08-26 12:18:17 +10:00
|
|
|
draw_editnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
|
2012-03-10 22:00:55 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
else if (dt == OB_BOUNDBOX) {
|
|
|
|
|
if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
|
2014-02-12 14:06:13 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
ensure_curve_cache(scene, base->object);
|
|
|
|
|
#endif
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2013-10-21 15:44:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-03-20 12:17:44 +11:00
|
|
|
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
2013-10-21 15:44:09 +00:00
|
|
|
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
2012-03-10 22:00:55 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_MBALL:
|
|
|
|
|
{
|
|
|
|
|
MetaBall *mb = ob->data;
|
|
|
|
|
|
|
|
|
|
if (mb->editelems)
|
|
|
|
|
drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
|
|
|
|
else if (dt == OB_BOUNDBOX) {
|
|
|
|
|
if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
|
2014-02-12 14:06:13 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
ensure_curve_cache(scene, base->object);
|
|
|
|
|
#endif
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2013-10-21 15:44:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
|
|
|
|
break;
|
2010-05-20 09:17:49 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
case OB_EMPTY:
|
|
|
|
|
if (!render_override) {
|
|
|
|
|
if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
|
|
|
|
|
draw_empty_image(ob, dflag, ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
drawaxes(ob->empty_drawsize, ob->empty_drawtype);
|
|
|
|
|
}
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_LAMP:
|
|
|
|
|
if (!render_override) {
|
2014-04-11 15:41:20 +10:00
|
|
|
drawlamp(v3d, rv3d, base, dt, dflag, ob_wire_col, is_obact);
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_CAMERA:
|
|
|
|
|
if (!render_override ||
|
|
|
|
|
(rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */
|
|
|
|
|
{
|
|
|
|
|
drawcamera(scene, v3d, rv3d, base, dflag, ob_wire_col);
|
2013-06-14 15:11:28 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_SPEAKER:
|
|
|
|
|
if (!render_override)
|
|
|
|
|
drawspeaker(scene, v3d, rv3d, ob, dflag);
|
|
|
|
|
break;
|
|
|
|
|
case OB_LATTICE:
|
|
|
|
|
if (!render_override) {
|
|
|
|
|
/* Do not allow boundbox in edit nor pose mode! */
|
|
|
|
|
if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT))
|
|
|
|
|
dt = OB_WIRE;
|
|
|
|
|
if (dt == OB_BOUNDBOX) {
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2013-10-21 15:44:09 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2014-02-12 14:06:13 +06:00
|
|
|
#ifdef SEQUENCER_DAG_WORKAROUND
|
|
|
|
|
ensure_curve_cache(scene, ob);
|
|
|
|
|
#endif
|
2014-01-13 16:33:18 +06:00
|
|
|
drawlattice(v3d, ob);
|
2013-10-21 15:44:09 +00:00
|
|
|
}
|
2013-06-14 15:11:28 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
case OB_ARMATURE:
|
|
|
|
|
if (!render_override) {
|
|
|
|
|
/* Do not allow boundbox in edit nor pose mode! */
|
|
|
|
|
if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE)))
|
|
|
|
|
dt = OB_WIRE;
|
|
|
|
|
if (dt == OB_BOUNDBOX) {
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2013-10-21 15:44:09 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false);
|
|
|
|
|
}
|
2012-03-22 13:27:24 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (!render_override) {
|
|
|
|
|
drawaxes(1.0, OB_ARROWS);
|
2012-03-22 13:27:24 +00:00
|
|
|
}
|
2013-10-21 15:44:09 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2010-03-16 17:49:31 +00:00
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if (!render_override) {
|
|
|
|
|
if (ob->soft /*&& dflag & OB_SBMOTION*/) {
|
|
|
|
|
float mrt[3][3], msc[3][3], mtr[3][3];
|
|
|
|
|
SoftBody *sb = NULL;
|
|
|
|
|
float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f;
|
|
|
|
|
if ((sb = ob->soft)) {
|
|
|
|
|
if (sb->solverflags & SBSO_ESTIMATEIPO) {
|
|
|
|
|
|
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
copy_m3_m3(msc, sb->lscale);
|
|
|
|
|
copy_m3_m3(mrt, sb->lrot);
|
|
|
|
|
mul_m3_m3m3(mtr, mrt, msc);
|
|
|
|
|
ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize);
|
|
|
|
|
glMultMatrixf(ob->obmat);
|
|
|
|
|
}
|
2010-03-16 17:49:31 +00:00
|
|
|
}
|
2009-10-18 16:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if (ob->pd && ob->pd->forcefield) {
|
|
|
|
|
draw_forcefield(ob, rv3d, dflag, ob_wire_col);
|
|
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* code for new particle system */
|
2013-04-20 05:50:22 +00:00
|
|
|
if ((ob->particlesystem.first) &&
|
|
|
|
|
(ob != scene->obedit))
|
2012-03-18 06:01:33 +00:00
|
|
|
{
|
2008-12-19 12:14:58 +00:00
|
|
|
ParticleSystem *psys;
|
2009-12-07 17:55:58 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
/* for visibility, also while wpaint */
|
|
|
|
|
if (col || (ob->flag & SELECT)) {
|
|
|
|
|
cpack(0xFFFFFF);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-04 03:50:12 +00:00
|
|
|
//glDepthMask(GL_FALSE);
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-09-19 18:45:31 +00:00
|
|
|
view3d_cached_text_draw_begin();
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
|
2009-12-07 17:55:58 +00:00
|
|
|
/* run this so that possible child particles get cached */
|
2011-12-03 20:26:53 +00:00
|
|
|
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
|
2010-03-09 03:27:05 +00:00
|
|
|
PTCacheEdit *edit = PE_create_current(scene, ob);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (edit && edit->psys == psys)
|
2009-12-07 18:17:39 +00:00
|
|
|
draw_update_ptcache_edit(scene, ob, edit);
|
2010-03-09 03:27:05 +00:00
|
|
|
}
|
2009-12-07 17:55:58 +00:00
|
|
|
|
2014-06-04 14:22:29 +10:00
|
|
|
draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
|
2009-12-07 17:55:58 +00:00
|
|
|
}
|
2010-10-19 02:41:09 +00:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
2009-09-19 18:45:31 +00:00
|
|
|
view3d_cached_text_draw_end(v3d, ar, 0, NULL);
|
2009-07-04 03:50:12 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMultMatrixf(ob->obmat);
|
2009-07-04 03:50:12 +00:00
|
|
|
|
|
|
|
|
//glDepthMask(GL_TRUE);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (col) cpack(col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-07 17:55:58 +00:00
|
|
|
/* draw edit particles last so that they can draw over child particles */
|
2013-04-20 05:50:22 +00:00
|
|
|
if ((dflag & DRAW_PICKING) == 0 &&
|
2012-09-09 00:00:21 +00:00
|
|
|
(!scene->obedit))
|
2011-12-03 20:26:53 +00:00
|
|
|
{
|
2009-12-07 17:55:58 +00:00
|
|
|
|
2011-12-03 20:26:53 +00:00
|
|
|
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
|
2010-03-09 03:27:05 +00:00
|
|
|
PTCacheEdit *edit = PE_create_current(scene, ob);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (edit) {
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2010-10-19 09:28:38 +00:00
|
|
|
draw_update_ptcache_edit(scene, ob, edit);
|
2010-10-14 01:22:14 +00:00
|
|
|
draw_ptcache_edit(scene, v3d, edit);
|
2010-02-01 15:32:55 +00:00
|
|
|
glMultMatrixf(ob->obmat);
|
2009-12-07 17:55:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-30 15:00:26 +00:00
|
|
|
/* draw code for smoke */
|
2015-04-16 13:01:57 +02:00
|
|
|
if (smd) {
|
2015-03-30 01:25:34 -04:00
|
|
|
#if 0
|
2015-03-30 00:51:00 -04:00
|
|
|
/* draw collision objects */
|
2012-03-06 18:40:15 +00:00
|
|
|
if ((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll) {
|
2012-03-03 16:31:46 +00:00
|
|
|
SmokeCollSettings *scs = smd->coll;
|
2012-03-06 18:40:15 +00:00
|
|
|
if (scs->points) {
|
2009-09-09 18:39:40 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2009-09-09 18:39:40 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (col || (ob->flag & SELECT)) cpack(0xFFFFFF);
|
2009-09-09 18:39:40 +00:00
|
|
|
glDepthMask(GL_FALSE);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// glPointSize(3.0);
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
for (i = 0; i < scs->numpoints; i++)
|
2009-09-09 18:39:40 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
bglVertex3fv(&scs->points[3 * i]);
|
2009-09-09 18:39:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bglEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMultMatrixf(ob->obmat);
|
2009-09-09 18:39:40 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
glDepthMask(GL_TRUE);
|
2012-02-22 16:52:06 +00:00
|
|
|
if (col) cpack(col);
|
2009-09-09 18:39:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-03-30 01:25:34 -04:00
|
|
|
#endif
|
2009-09-09 18:39:40 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* only draw domains */
|
2012-10-10 13:18:07 +00:00
|
|
|
if (smd->domain) {
|
|
|
|
|
SmokeDomainSettings *sds = smd->domain;
|
2015-06-07 21:52:11 +10:00
|
|
|
float viewnormal[3];
|
2009-09-14 10:37:13 +00:00
|
|
|
|
2012-10-10 13:18:07 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
glMultMatrixf(ob->obmat);
|
2009-09-14 10:37:13 +00:00
|
|
|
|
2012-10-10 13:18:07 +00:00
|
|
|
/* draw adaptive domain bounds */
|
2015-06-07 21:52:11 +10:00
|
|
|
if ((sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN) && !render_override) {
|
|
|
|
|
float p0[3], p1[3];
|
|
|
|
|
BoundBox bb;
|
2012-10-10 13:18:07 +00:00
|
|
|
/* draw domain max bounds */
|
|
|
|
|
VECSUBFAC(p0, sds->p0, sds->cell_size, sds->adapt_res);
|
|
|
|
|
VECADDFAC(p1, sds->p1, sds->cell_size, sds->adapt_res);
|
|
|
|
|
BKE_boundbox_init_from_minmax(&bb, p0, p1);
|
2015-04-18 12:28:19 +02:00
|
|
|
draw_box(bb.vec, false);
|
2009-09-14 10:37:13 +00:00
|
|
|
|
2012-10-11 03:25:19 +00:00
|
|
|
#if 0
|
2015-03-30 00:51:00 -04:00
|
|
|
/* draw base resolution bounds */
|
2012-10-11 03:25:19 +00:00
|
|
|
BKE_boundbox_init_from_minmax(&bb, sds->p0, sds->p1);
|
|
|
|
|
draw_box(bb.vec);
|
|
|
|
|
#endif
|
2012-10-10 13:18:07 +00:00
|
|
|
}
|
2009-09-14 10:37:13 +00:00
|
|
|
|
2012-10-10 13:18:07 +00:00
|
|
|
/* don't show smoke before simulation starts, this could be made an option in the future */
|
2015-11-22 18:17:09 +01:00
|
|
|
if (sds->fluid && CFRA >= sds->point_cache[0]->startframe) {
|
2015-06-07 21:52:11 +10:00
|
|
|
float p0[3], p1[3];
|
|
|
|
|
|
2015-03-30 00:51:00 -04:00
|
|
|
/* get view vector */
|
2013-08-23 22:57:29 +00:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
2015-04-27 23:23:04 +10:00
|
|
|
mul_v3_mat3_m4v3(viewnormal, ob->imat, rv3d->viewinv[2]);
|
2012-10-10 13:18:07 +00:00
|
|
|
normalize_v3(viewnormal);
|
|
|
|
|
|
2013-08-01 12:09:12 +00:00
|
|
|
/* set dynamic boundaries to draw the volume
|
2015-03-30 00:51:00 -04:00
|
|
|
* also scale cube to global space to equalize volume slicing on all axes
|
|
|
|
|
* (it's scaled back before drawing) */
|
2013-08-06 06:38:52 +00:00
|
|
|
p0[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
|
|
|
|
|
p0[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
|
|
|
|
|
p0[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
|
|
|
|
|
p1[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
|
|
|
|
|
p1[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
|
|
|
|
|
p1[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
|
2012-10-10 13:18:07 +00:00
|
|
|
|
|
|
|
|
if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
|
2015-11-22 18:17:09 +01:00
|
|
|
sds->tex = NULL;
|
2012-10-10 13:18:07 +00:00
|
|
|
GPU_create_smoke(smd, 0);
|
2015-12-06 21:41:21 +01:00
|
|
|
draw_smoke_volume(sds, ob, p0, p1, viewnormal);
|
2012-10-10 13:18:07 +00:00
|
|
|
GPU_free_smoke(smd);
|
|
|
|
|
}
|
|
|
|
|
else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
|
|
|
|
|
sds->tex = NULL;
|
|
|
|
|
GPU_create_smoke(smd, 1);
|
2015-12-06 21:41:21 +01:00
|
|
|
draw_smoke_volume(sds, ob, p0, p1, viewnormal);
|
2012-10-10 13:18:07 +00:00
|
|
|
GPU_free_smoke(smd);
|
2009-09-14 10:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-10 13:18:07 +00:00
|
|
|
/* smoke debug render */
|
2012-10-11 03:25:19 +00:00
|
|
|
#ifdef SMOKE_DEBUG_VELOCITY
|
|
|
|
|
draw_smoke_velocity(smd->domain, ob);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef SMOKE_DEBUG_HEAT
|
|
|
|
|
draw_smoke_heat(smd->domain, ob);
|
2009-09-14 10:37:13 +00:00
|
|
|
#endif
|
2009-07-30 15:00:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if (!render_override) {
|
2008-12-19 12:14:58 +00:00
|
|
|
bConstraint *con;
|
2012-03-06 18:40:15 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (con = ob->constraints.first; con; con = con->next) {
|
|
|
|
|
if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) {
|
|
|
|
|
bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data;
|
|
|
|
|
if (data->flag & CONSTRAINT_DRAW_PIVOT)
|
2012-07-25 12:55:55 +00:00
|
|
|
draw_rigid_body_pivot(data, dflag, ob_wire_col);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-20 06:22:17 +00:00
|
|
|
if ((ob->gameflag & OB_BOUNDS) && (ob->mode == OB_MODE_OBJECT)) {
|
2013-01-18 19:01:26 +00:00
|
|
|
if (ob->boundtype != ob->collision_boundtype || (dtx & OB_DRAWBOUNDOX) == 0) {
|
2011-11-04 15:53:34 +00:00
|
|
|
setlinestyle(2);
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->collision_boundtype);
|
2011-11-04 15:53:34 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-25 19:05:55 +01:00
|
|
|
if (ob->rigidbody_object) {
|
|
|
|
|
draw_rigidbody_shape(ob);
|
|
|
|
|
}
|
2011-11-04 15:53:34 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* draw extra: after normal draw because of makeDispList */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dtx && (G.f & G_RENDER_OGL) == 0) {
|
2010-07-26 21:35:24 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (dtx & OB_AXIS) {
|
2010-10-14 01:22:14 +00:00
|
|
|
drawaxes(1.0f, OB_ARROWS);
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2013-01-18 19:01:26 +00:00
|
|
|
if (dtx & OB_DRAWBOUNDOX) {
|
2014-01-13 16:33:18 +06:00
|
|
|
draw_bounding_volume(ob, ob->boundtype);
|
2010-05-20 15:04:47 +00:00
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
if (dtx & OB_TEXSPACE) {
|
2013-04-20 06:22:17 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
/* prevent random colors being used */
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
drawtexspace(ob);
|
|
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
if (dtx & OB_DRAWNAME) {
|
2012-05-04 11:50:11 +00:00
|
|
|
/* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */
|
2012-03-18 07:38:51 +00:00
|
|
|
/* but, we also don't draw names for sets or duplicators */
|
2012-06-10 10:15:49 +00:00
|
|
|
if (dflag == 0) {
|
2012-06-06 18:00:08 +00:00
|
|
|
const float zero[3] = {0, 0, 0};
|
2014-04-17 15:14:07 +10:00
|
|
|
view3d_cached_text_draw_add(zero, ob->id.name + 2, strlen(ob->id.name + 2), 10, 0, ob_wire_col);
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
if ((dtx & OB_DRAWWIRE) && dt >= OB_SOLID) {
|
2012-08-16 17:42:06 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
draw_wire_extra(scene, rv3d, ob, ob_wire_col);
|
|
|
|
|
}
|
2012-03-06 18:40:15 +00:00
|
|
|
}
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if ((dt <= OB_SOLID) && !render_override) {
|
2012-06-29 20:26:07 +00:00
|
|
|
if (((ob->gameflag & OB_DYNAMIC) &&
|
2015-03-09 17:24:14 +11:00
|
|
|
((ob->gameflag & OB_BOUNDS) == 0)) ||
|
2012-06-29 20:26:07 +00:00
|
|
|
|
|
|
|
|
((ob->gameflag & OB_BOUNDS) &&
|
2015-03-09 17:24:14 +11:00
|
|
|
(ob->collision_boundtype == OB_BOUND_SPHERE)))
|
2012-03-06 18:40:15 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
float imat[4][4], vec[3] = {0.0f, 0.0f, 0.0f};
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
invert_m4_m4(imat, rv3d->viewmatob);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-04-20 17:24:40 +00:00
|
|
|
if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
|
|
|
|
/* prevent random colors being used */
|
|
|
|
|
glColor3ubv(ob_wire_col);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(2);
|
|
|
|
|
drawcircball(GL_LINE_LOOP, vec, ob->inertia, imat);
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-18 16:42:34 +00:00
|
|
|
|
|
|
|
|
/* return warning, this is cached text draw */
|
2010-10-19 02:41:09 +00:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
2009-09-19 18:45:31 +00:00
|
|
|
view3d_cached_text_draw_end(v3d, ar, 1, NULL);
|
2013-01-22 11:18:41 +00:00
|
|
|
/* return warning, clear temp flag */
|
|
|
|
|
v3d->flag2 &= ~V3D_SHOW_SOLID_MATCAP;
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if (zbufoff) {
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if ((base->flag & OB_FROMDUPLI) || render_override) {
|
2013-05-08 13:00:52 +00:00
|
|
|
ED_view3d_clear_mats_rv3d(rv3d);
|
2012-03-06 18:40:15 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* object centers, need to be drawn in viewmat space for speed, but OK for picking select */
|
2012-09-26 22:39:10 +00:00
|
|
|
if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
int do_draw_center = -1; /* defines below are zero or positive... */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-21 15:44:09 +00:00
|
|
|
if (render_override) {
|
2012-03-18 07:38:51 +00:00
|
|
|
/* don't draw */
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
2015-02-03 09:32:19 +11:00
|
|
|
else if (is_obact)
|
2012-03-25 23:54:33 +00:00
|
|
|
do_draw_center = ACTIVE;
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (base->flag & SELECT)
|
2012-03-25 23:54:33 +00:00
|
|
|
do_draw_center = SELECT;
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (empty_object || (v3d->flag & V3D_DRAW_CENTERS))
|
2012-03-25 23:54:33 +00:00
|
|
|
do_draw_center = DESELECT;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (do_draw_center != -1) {
|
2012-06-10 10:15:49 +00:00
|
|
|
if (dflag & DRAW_PICKING) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* draw a single point for opengl selection */
|
|
|
|
|
glBegin(GL_POINTS);
|
|
|
|
|
glVertex3fv(ob->obmat[3]);
|
|
|
|
|
glEnd();
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2012-06-10 10:15:49 +00:00
|
|
|
else if ((dflag & DRAW_CONSTCOLOR) == 0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
/* we don't draw centers for duplicators and sets */
|
2014-02-05 22:13:18 +01:00
|
|
|
if (U.obcenter_dia > 0 && !(G.f & G_RENDER_OGL)) {
|
2010-03-22 09:30:00 +00:00
|
|
|
/* check > 0 otherwise grease pencil can draw into the circle select which is annoying. */
|
2012-03-25 23:54:33 +00:00
|
|
|
drawcentercircle(v3d, rv3d, ob->obmat[3], do_draw_center, ob->id.lib || ob->id.us > 1);
|
2010-01-03 01:55:20 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* not for sets, duplicators or picking */
|
2013-10-21 15:44:09 +00:00
|
|
|
if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && !render_override) {
|
2008-12-19 12:14:58 +00:00
|
|
|
ListBase *list;
|
2013-04-18 15:09:30 +00:00
|
|
|
RigidBodyCon *rbc = ob->rigidbody_constraint;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* draw hook center and offset line */
|
2013-04-18 15:09:30 +00:00
|
|
|
if (ob != scene->obedit)
|
|
|
|
|
draw_hooks(ob);
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* help lines and so */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (ob != scene->obedit && ob->parent && (ob->parent->lay & v3d->lay)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(ob->obmat[3]);
|
|
|
|
|
glVertex3fv(ob->orig);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Drawing the constraint lines */
|
2010-12-23 13:16:56 +00:00
|
|
|
if (ob->constraints.first) {
|
2008-12-19 12:14:58 +00:00
|
|
|
bConstraint *curcon;
|
|
|
|
|
bConstraintOb *cob;
|
2010-12-20 03:59:22 +00:00
|
|
|
unsigned char col1[4], col2[4];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-12-23 13:16:56 +00:00
|
|
|
list = &ob->constraints;
|
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
UI_GetThemeColor3ubv(TH_GRID, col1);
|
2010-12-20 03:59:22 +00:00
|
|
|
UI_make_axis_color(col1, col2, 'Z');
|
|
|
|
|
glColor3ubv(col2);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
for (curcon = list->first; curcon; curcon = curcon->next) {
|
2013-08-03 22:03:15 +00:00
|
|
|
if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) {
|
2011-12-15 20:38:23 +00:00
|
|
|
/* special case for object solver and follow track constraints because they don't fill
|
2012-03-03 16:31:46 +00:00
|
|
|
* constraint targets properly (design limitation -- scene is needed for their target
|
2015-03-30 00:51:00 -04:00
|
|
|
* but it can't be accessed from get_targets callback) */
|
2011-12-15 20:38:23 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
Object *camob = NULL;
|
2011-12-15 20:38:23 +00:00
|
|
|
|
2013-08-03 22:03:15 +00:00
|
|
|
if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
|
2012-03-25 23:54:33 +00:00
|
|
|
bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data;
|
2011-12-15 20:38:23 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
camob = data->camera ? data->camera : scene->camera;
|
2011-12-15 20:38:23 +00:00
|
|
|
}
|
2013-08-03 22:03:15 +00:00
|
|
|
else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
|
2012-03-25 23:54:33 +00:00
|
|
|
bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data;
|
2011-12-15 20:38:23 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
camob = data->camera ? data->camera : scene->camera;
|
2011-12-15 20:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (camob) {
|
2011-12-15 16:09:57 +00:00
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINES);
|
2011-12-15 20:38:23 +00:00
|
|
|
glVertex3fv(camob->obmat[3]);
|
2011-12-15 16:09:57 +00:00
|
|
|
glVertex3fv(ob->obmat[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-03 22:03:15 +00:00
|
|
|
else {
|
2015-03-30 21:17:07 +11:00
|
|
|
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
|
2013-08-03 22:03:15 +00:00
|
|
|
|
|
|
|
|
if ((cti && cti->get_constraint_targets) && (curcon->flag & CONSTRAINT_EXPAND)) {
|
|
|
|
|
ListBase targets = {NULL, NULL};
|
|
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
|
|
cti->get_constraint_targets(curcon, &targets);
|
|
|
|
|
|
|
|
|
|
for (ct = targets.first; ct; ct = ct->next) {
|
|
|
|
|
/* calculate target's matrix */
|
|
|
|
|
if (cti->get_target_matrix)
|
|
|
|
|
cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene));
|
|
|
|
|
else
|
|
|
|
|
unit_m4(ct->matrix);
|
|
|
|
|
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
glVertex3fv(ct->matrix[3]);
|
|
|
|
|
glVertex3fv(ob->obmat[3]);
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cti->flush_constraint_targets)
|
|
|
|
|
cti->flush_constraint_targets(curcon, &targets, 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraints_clear_evalob(cob);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2013-03-31 19:52:37 +00:00
|
|
|
/* draw rigid body constraint lines */
|
|
|
|
|
if (rbc) {
|
|
|
|
|
UI_ThemeColor(TH_WIRE);
|
|
|
|
|
setlinestyle(3);
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
if (rbc->ob1) {
|
|
|
|
|
glVertex3fv(ob->obmat[3]);
|
|
|
|
|
glVertex3fv(rbc->ob1->obmat[3]);
|
|
|
|
|
}
|
|
|
|
|
if (rbc->ob2) {
|
|
|
|
|
glVertex3fv(ob->obmat[3]);
|
|
|
|
|
glVertex3fv(rbc->ob2->obmat[3]);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-08 13:00:52 +00:00
|
|
|
ED_view3d_clear_mats_rv3d(rv3d);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ***************** BACKBUF SEL (BBS) ********* */
|
2011-09-18 17:10:28 +00:00
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, const float co[3],
|
|
|
|
|
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
|
2011-08-09 16:32:15 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawMVertOffset_userData *data = userData;
|
2011-09-19 02:43:03 +00:00
|
|
|
MVert *mv = &data->mvert[index];
|
2011-08-09 16:32:15 +00:00
|
|
|
|
2011-09-18 01:09:18 +00:00
|
|
|
if (!(mv->flag & ME_HIDE)) {
|
2014-06-19 18:36:49 +10:00
|
|
|
WM_framebuffer_index_set(data->offset + index);
|
2011-09-18 01:09:18 +00:00
|
|
|
bglVertex3fv(co);
|
|
|
|
|
}
|
2011-08-09 16:32:15 +00:00
|
|
|
}
|
2011-09-18 17:10:28 +00:00
|
|
|
|
2011-09-18 01:09:18 +00:00
|
|
|
static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
|
2011-08-09 16:32:15 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawMVertOffset_userData data;
|
2011-09-18 01:09:18 +00:00
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
MVert *mvert = me->mvert;
|
|
|
|
|
data.mvert = mvert;
|
2014-06-19 18:36:49 +10:00
|
|
|
data.offset = offset;
|
2012-04-29 17:55:54 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
2011-08-09 16:32:15 +00:00
|
|
|
bglBegin(GL_POINTS);
|
2013-07-22 22:59:47 +00:00
|
|
|
dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data, DM_FOREACH_NOP);
|
2011-08-09 16:32:15 +00:00
|
|
|
bglEnd();
|
|
|
|
|
glPointSize(1.0);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3],
|
|
|
|
|
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawBMOffset_userData *data = userData;
|
|
|
|
|
BMVert *eve = BM_vert_at_index(data->bm, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
|
2014-06-19 18:36:49 +10:00
|
|
|
WM_framebuffer_index_set(data->offset + index);
|
2008-12-19 12:14:58 +00:00
|
|
|
bglVertex3fv(co);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-18 08:46:04 +00:00
|
|
|
static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawBMOffset_userData data = {em->bm, offset};
|
2012-04-29 17:55:54 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
|
2008-12-19 12:14:58 +00:00
|
|
|
bglBegin(GL_POINTS);
|
2014-06-19 18:36:49 +10:00
|
|
|
dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, &data, DM_FOREACH_NOP);
|
2008-12-19 12:14:58 +00:00
|
|
|
bglEnd();
|
|
|
|
|
glPointSize(1.0);
|
2012-10-11 03:25:19 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawBMOffset_userData *data = userData;
|
|
|
|
|
BMEdge *eed = BM_edge_at_index(data->bm, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
|
2014-06-19 18:36:49 +10:00
|
|
|
WM_framebuffer_index_set(data->offset + index);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-05-18 08:46:04 +00:00
|
|
|
static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
drawBMOffset_userData data = {em->bm, offset};
|
|
|
|
|
dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, &data);
|
2012-10-11 03:25:19 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-06-19 18:36:49 +10:00
|
|
|
/**
|
|
|
|
|
* dont set #WM_framebuffer_index_set. just use to mask other
|
|
|
|
|
*/
|
|
|
|
|
static DMDrawOption bbs_mesh_mask__setSolidDrawOptions(void *userData, int index)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
BMFace *efa = BM_face_at_index(userData, index);
|
2011-06-01 19:30:19 +00:00
|
|
|
|
2013-06-20 07:00:57 +00:00
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2014-06-19 18:36:49 +10:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return DM_DRAW_OPTION_SKIP;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int index)
|
|
|
|
|
{
|
|
|
|
|
BMFace *efa = BM_face_at_index(userData, index);
|
|
|
|
|
|
|
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
|
|
|
|
WM_framebuffer_index_set(index + 1);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-09 07:06:06 +00:00
|
|
|
static void bbs_mesh_solid__drawCenter(void *userData, int index, const float cent[3], const float UNUSED(no[3]))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2014-06-19 18:36:49 +10:00
|
|
|
BMFace *efa = BM_face_at_index(userData, index);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-12 10:51:45 +00:00
|
|
|
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
2012-08-11 21:35:24 +00:00
|
|
|
WM_framebuffer_index_set(index + 1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
bglVertex3fv(cent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* two options, facecolors or black */
|
2009-05-18 08:46:04 +00:00
|
|
|
static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d,
|
2014-06-19 18:36:49 +10:00
|
|
|
Object *ob, DerivedMesh *dm, bool use_faceselect)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
cpack(0);
|
|
|
|
|
|
2014-06-19 18:36:49 +10:00
|
|
|
if (use_faceselect) {
|
2015-07-29 16:18:33 +02:00
|
|
|
dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, NULL, NULL, em->bm, DM_DRAW_SKIP_HIDDEN | DM_DRAW_SELECT_USE_EDITMODE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (check_ob_drawface_dot(scene, v3d, ob->dt)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
bglBegin(GL_POINTS);
|
2014-06-19 18:36:49 +10:00
|
|
|
dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, em->bm, DM_FOREACH_NOP);
|
2008-12-19 12:14:58 +00:00
|
|
|
bglEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2015-07-29 16:18:33 +02:00
|
|
|
dm->drawMappedFaces(dm, bbs_mesh_mask__setSolidDrawOptions, NULL, NULL, em->bm, DM_DRAW_SKIP_SELECT | DM_DRAW_SKIP_HIDDEN | DM_DRAW_SELECT_USE_EDITMODE);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index)
|
2009-10-19 15:01:07 +00:00
|
|
|
{
|
2012-08-11 21:35:24 +00:00
|
|
|
WM_framebuffer_index_set(index + 1);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2009-10-19 15:01:07 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index)
|
2009-10-03 15:35:01 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = userData;
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (!(me->mpoly[index].flag & ME_HIDE)) {
|
2012-08-11 21:35:24 +00:00
|
|
|
WM_framebuffer_index_set(index + 1);
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-09-18 17:10:28 +00:00
|
|
|
|
2012-08-11 21:35:24 +00:00
|
|
|
/* must have called WM_framebuffer_index_set beforehand */
|
2012-03-08 06:47:05 +00:00
|
|
|
static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index)
|
2011-08-09 16:32:15 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me = userData;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-05 03:25:13 +00:00
|
|
|
if (!(me->mpoly[index].flag & ME_HIDE)) {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_NORMAL;
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-08 06:47:05 +00:00
|
|
|
return DM_DRAW_OPTION_SKIP;
|
2011-08-09 16:32:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-12-23 08:20:44 +00:00
|
|
|
|
|
|
|
|
static void bbs_mesh_solid_verts(Scene *scene, Object *ob)
|
|
|
|
|
{
|
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
|
|
|
|
|
glColor3ub(0, 0, 0);
|
|
|
|
|
|
2014-04-09 19:51:29 +03:00
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, GPU_object_material_bind, NULL, me, DM_DRAW_SKIP_HIDDEN);
|
2012-12-23 08:20:44 +00:00
|
|
|
|
|
|
|
|
bbs_obmode_mesh_verts(ob, dm, 1);
|
|
|
|
|
bm_vertoffs = me->totvert + 1;
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bbs_mesh_solid_faces(Scene *scene, Object *ob)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2010-12-23 04:26:53 +00:00
|
|
|
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
|
2015-03-30 00:51:00 -04:00
|
|
|
Mesh *me = ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glColor3ub(0, 0, 0);
|
2011-12-03 20:49:41 +00:00
|
|
|
|
2014-04-09 19:51:29 +03:00
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
|
2012-12-22 14:25:34 +00:00
|
|
|
if ((me->editflag & ME_EDIT_PAINT_FACE_SEL))
|
2015-07-15 18:50:02 +02:00
|
|
|
dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, NULL, NULL, me, DM_DRAW_SKIP_HIDDEN);
|
2011-12-03 20:49:41 +00:00
|
|
|
else
|
2015-01-11 21:28:30 +01:00
|
|
|
dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, NULL, NULL, me, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
}
|
|
|
|
|
|
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_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
ToolSettings *ts = scene->toolsettings;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMultMatrixf(ob->obmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (ob->type) {
|
2012-03-18 06:01:33 +00:00
|
|
|
case OB_MESH:
|
|
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
BMEditMesh *em = me->edit_btmesh;
|
2009-02-19 23:53:40 +00:00
|
|
|
|
2012-03-18 06:01:33 +00:00
|
|
|
DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-10-28 02:05:33 +00:00
|
|
|
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-04-10 01:16:17 +03:00
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
|
2014-06-19 18:36:49 +10:00
|
|
|
bbs_mesh_solid_EM(em, scene, v3d, ob, dm, (ts->selectmode & SCE_SELECT_FACE) != 0);
|
2012-03-18 06:01:33 +00:00
|
|
|
if (ts->selectmode & SCE_SELECT_FACE)
|
2012-03-25 23:54:33 +00:00
|
|
|
bm_solidoffs = 1 + em->bm->totface;
|
2012-03-18 06:01:33 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
bm_solidoffs = 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 1.0);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* we draw edges always, for loop (select) tools */
|
2012-03-18 06:01:33 +00:00
|
|
|
bbs_mesh_wire(em, dm, bm_solidoffs);
|
2012-03-25 23:54:33 +00:00
|
|
|
bm_wireoffs = bm_solidoffs + em->bm->totedge;
|
2011-08-09 16:32:15 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* we draw verts if vert select mode or if in transform (for snap). */
|
2012-03-18 06:01:33 +00:00
|
|
|
if ((ts->selectmode & SCE_SELECT_VERTEX) || (G.moving & G_TRANSFORM_EDIT)) {
|
|
|
|
|
bbs_mesh_verts(em, dm, bm_wireoffs);
|
2012-03-25 23:54:33 +00:00
|
|
|
bm_vertoffs = bm_wireoffs + em->bm->totvert;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bm_vertoffs = bm_wireoffs;
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-09 20:59:29 +11:00
|
|
|
ED_view3d_polygon_offset(rv3d, 0.0);
|
2011-08-09 16:32:15 +00:00
|
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
}
|
2011-09-13 06:39:17 +00:00
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = ob->data;
|
2012-12-22 14:25:34 +00:00
|
|
|
if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) &&
|
2012-03-25 23:54:33 +00:00
|
|
|
/* currently vertex select only supports weight paint */
|
|
|
|
|
(ob->mode & OB_MODE_WEIGHT_PAINT))
|
2012-03-18 06:01:33 +00:00
|
|
|
{
|
2012-12-23 08:20:44 +00:00
|
|
|
bbs_mesh_solid_verts(scene, ob);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-12-23 08:20:44 +00:00
|
|
|
bbs_mesh_solid_faces(scene, ob);
|
2012-03-18 06:01:33 +00:00
|
|
|
}
|
2011-09-13 06:39:17 +00:00
|
|
|
}
|
2012-03-18 06:01:33 +00:00
|
|
|
break;
|
|
|
|
|
case OB_CURVE:
|
|
|
|
|
case OB_SURF:
|
|
|
|
|
break;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************* draw object instances for bones, for example ****************** */
|
|
|
|
|
/* assumes all matrices/etc set OK */
|
|
|
|
|
|
|
|
|
|
/* helper function for drawing object instances - meshes */
|
2012-10-11 03:25:19 +00:00
|
|
|
static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d,
|
2012-06-10 10:15:49 +00:00
|
|
|
Object *ob, const short dt, int outline)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Mesh *me = ob->data;
|
|
|
|
|
DerivedMesh *dm = NULL, *edm = NULL;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2014-04-10 01:16:17 +03:00
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
2012-03-25 23:54:33 +00:00
|
|
|
edm = editbmesh_get_derived_base(ob, me->edit_btmesh);
|
2014-04-17 18:05:57 +10:00
|
|
|
DM_update_materials(edm, ob);
|
2014-04-10 01:16:17 +03:00
|
|
|
}
|
|
|
|
|
else {
|
2009-01-04 14:14:06 +00:00
|
|
|
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
|
2014-04-10 01:16:17 +03:00
|
|
|
DM_update_materials(dm, ob);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (dt <= OB_WIRE) {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (dm)
|
2010-03-22 11:59:36 +00:00
|
|
|
dm->drawEdges(dm, 1, 0);
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (edm)
|
2012-03-18 06:01:33 +00:00
|
|
|
edm->drawEdges(edm, 1, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-02-22 16:52:06 +00:00
|
|
|
if (outline)
|
2012-03-25 23:54:33 +00:00
|
|
|
draw_mesh_object_outline(v3d, ob, dm ? dm : edm);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (dm) {
|
2015-12-16 01:24:15 -05:00
|
|
|
bool glsl = draw_glsl_material(scene, ob, v3d, dt);
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (dm) {
|
2015-11-23 21:42:17 +01:00
|
|
|
dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
|
2009-07-13 00:40:20 +00:00
|
|
|
GPU_end_object_materials();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
else if (edm)
|
2015-11-27 21:16:26 +01:00
|
|
|
edm->drawMappedFaces(edm, NULL, GPU_object_material_bind, NULL, NULL, DM_DRAW_NEED_NORMALS);
|
|
|
|
|
|
2015-11-27 21:32:14 +01:00
|
|
|
GPU_object_material_unbind();
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (edm) edm->release(edm);
|
|
|
|
|
if (dm) dm->release(dm);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-18 19:01:26 +00:00
|
|
|
void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const char dt, int outline)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2012-03-18 06:01:33 +00:00
|
|
|
if (ob == NULL)
|
2008-12-19 12:14:58 +00:00
|
|
|
return;
|
2012-03-18 06:01:33 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_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_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline);
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
case OB_EMPTY:
|
2011-05-09 16:31:54 +00:00
|
|
|
if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
|
2012-08-16 18:37:30 +00:00
|
|
|
/* CONSTCOLOR == no wire outline */
|
|
|
|
|
draw_empty_image(ob, DRAW_CONSTCOLOR, NULL);
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
drawaxes(ob->empty_drawsize, ob->empty_drawtype);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|