2017-02-17 17:29:43 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2016, Blender Foundation.
|
|
|
|
|
*
|
|
|
|
|
* 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,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Institute
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2017-02-22 13:00:15 +01:00
|
|
|
/** \file blender/draw/modes/edit_armature_mode.c
|
2017-02-17 17:29:43 +01:00
|
|
|
* \ingroup draw
|
|
|
|
|
*/
|
|
|
|
|
|
2017-02-17 17:53:51 +01:00
|
|
|
#include "DRW_engine.h"
|
2017-02-17 17:29:43 +01:00
|
|
|
#include "DRW_render.h"
|
|
|
|
|
|
2017-02-22 13:00:15 +01:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
#include "draw_common.h"
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
#include "draw_mode_engines.h"
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
extern GlobalsUboStorage ts;
|
|
|
|
|
|
|
|
|
|
/* *********** LISTS *********** */
|
2017-02-17 17:29:43 +01:00
|
|
|
/* keep it under MAX_PASSES */
|
2017-02-22 18:52:07 +01:00
|
|
|
typedef struct EDIT_ARMATURE_PassList {
|
2017-03-08 20:00:09 +01:00
|
|
|
struct DRWPass *bone_solid;
|
|
|
|
|
struct DRWPass *bone_wire;
|
|
|
|
|
struct DRWPass *relationship;
|
2017-02-22 13:00:15 +01:00
|
|
|
} EDIT_ARMATURE_PassList;
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
typedef struct EDIT_ARMATURE_Data {
|
|
|
|
|
char engine_name[32];
|
|
|
|
|
void *fbl;
|
|
|
|
|
void *txl;
|
|
|
|
|
EDIT_ARMATURE_PassList *psl;
|
|
|
|
|
void *stl;
|
|
|
|
|
} EDIT_ARMATURE_Data;
|
|
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
/* *********** STATIC *********** */
|
2017-03-08 20:00:09 +01:00
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
static struct {
|
|
|
|
|
DRWShadingGroup *relationship_lines;
|
|
|
|
|
EDIT_ARMATURE_Data *vedata;
|
|
|
|
|
} g_data = {NULL}; /* Transient data */
|
2017-03-08 20:00:09 +01:00
|
|
|
|
2017-03-18 22:14:53 +01:00
|
|
|
/* *********** FUNCTIONS *********** */
|
2017-03-08 20:00:09 +01:00
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void EDIT_ARMATURE_cache_init(void *vedata)
|
2017-02-17 17:29:43 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
|
|
|
|
|
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
{
|
|
|
|
|
/* Solid bones */
|
|
|
|
|
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
|
|
|
|
|
psl->bone_solid = DRW_pass_create("Bone Solid Pass", state);
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
{
|
|
|
|
|
/* Wire bones */
|
|
|
|
|
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND;
|
|
|
|
|
psl->bone_wire = DRW_pass_create("Bone Wire Pass", state);
|
|
|
|
|
}
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
{
|
|
|
|
|
/* Non Meshes Pass (Camera, empties, lamps ...) */
|
|
|
|
|
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND | DRW_STATE_WIRE;
|
|
|
|
|
psl->relationship = DRW_pass_create("Bone Relationship Pass", state);
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
/* Relationship Lines */
|
2017-03-18 22:14:53 +01:00
|
|
|
g_data.relationship_lines = shgroup_dynlines_uniform_color(psl->relationship, ts.colorWire);
|
|
|
|
|
DRW_shgroup_state_set(g_data.relationship_lines, DRW_STATE_STIPPLE_3);
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
|
2017-02-17 17:29:43 +01:00
|
|
|
{
|
2017-03-08 20:00:09 +01:00
|
|
|
bArmature *arm = ob->data;
|
2017-03-26 19:10:53 +02:00
|
|
|
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
|
2017-03-08 20:00:09 +01:00
|
|
|
|
|
|
|
|
if (ob->type == OB_ARMATURE) {
|
|
|
|
|
if (arm->edbo) {
|
2017-03-18 22:14:53 +01:00
|
|
|
DRW_shgroup_armature_edit(ob, psl->bone_solid, psl->bone_wire, g_data.relationship_lines);
|
2017-03-08 20:00:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-02-17 17:29:43 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-26 19:10:53 +02:00
|
|
|
static void EDIT_ARMATURE_draw_scene(void *vedata)
|
2017-02-17 17:29:43 +01:00
|
|
|
{
|
2017-03-26 19:10:53 +02:00
|
|
|
EDIT_ARMATURE_PassList *psl = ((EDIT_ARMATURE_Data *)vedata)->psl;
|
2017-02-17 17:29:43 +01:00
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
DRW_draw_pass(psl->bone_solid);
|
|
|
|
|
DRW_draw_pass(psl->bone_wire);
|
|
|
|
|
DRW_draw_pass(psl->relationship);
|
2017-02-17 17:53:51 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-14 18:40:23 +11:00
|
|
|
#if 0
|
2017-02-22 13:00:15 +01:00
|
|
|
void EDIT_ARMATURE_collection_settings_create(CollectionEngineSettings *ces)
|
2017-02-17 17:53:51 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ces);
|
2017-02-22 13:00:15 +01:00
|
|
|
//BKE_collection_engine_property_add_int(ces, "show_occlude_wire", false);
|
2017-02-17 17:53:51 +01:00
|
|
|
}
|
2017-03-14 18:40:23 +11:00
|
|
|
#endif
|
2017-03-08 20:00:09 +01:00
|
|
|
|
|
|
|
|
DrawEngineType draw_engine_edit_armature_type = {
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
N_("EditArmatureMode"),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&EDIT_ARMATURE_cache_init,
|
|
|
|
|
&EDIT_ARMATURE_cache_populate,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
&EDIT_ARMATURE_draw_scene
|
|
|
|
|
};
|