Dopesheet-Timeline: Ported over cache indicator drawing + settings used to control their visibility

These now live in the action editor/dopesheet related files.

Apart from these, the timeline didn't actually have other settings
of its own that were of any interest to anyone.
This commit is contained in:
2018-04-19 16:04:26 +02:00
parent cc06e0fbe8
commit b2eb76cd50
6 changed files with 210 additions and 11 deletions

View File

@@ -43,16 +43,23 @@
/* Types --------------------------------------------------------------- */
#include "DNA_anim_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_pointcache.h"
/* Everything from source (BIF, BDR, BSE) ------------------------------ */
#include "BIF_gl.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -61,7 +68,6 @@
#include "ED_keyframes_draw.h"
#include "action_intern.h"
#include "GPU_immediate.h"
/* ************************************************************************* */
/* Channel List */
@@ -381,3 +387,139 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* free temporary channels used for drawing */
ANIM_animdata_freelist(&anim_data);
}
/* ************************************************************************* */
/* Timeline - Caches */
void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
{
PTCacheID *pid;
ListBase pidlist;
const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
float yoffs = 0.f;
if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob))
return;
BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* iterate over pointcaches on the active object,
* add spacetimecache and vertex array for each */
for (pid = pidlist.first; pid; pid = pid->next) {
float col[4];
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
if (!(saction->cache_display & TIME_CACHE_SOFTBODY)) continue;
break;
case PTCACHE_TYPE_PARTICLES:
if (!(saction->cache_display & TIME_CACHE_PARTICLES)) continue;
break;
case PTCACHE_TYPE_CLOTH:
if (!(saction->cache_display & TIME_CACHE_CLOTH)) continue;
break;
case PTCACHE_TYPE_SMOKE_DOMAIN:
case PTCACHE_TYPE_SMOKE_HIGHRES:
if (!(saction->cache_display & TIME_CACHE_SMOKE)) continue;
break;
case PTCACHE_TYPE_DYNAMICPAINT:
if (!(saction->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
break;
case PTCACHE_TYPE_RIGIDBODY:
if (!(saction->cache_display & TIME_CACHE_RIGIDBODY)) continue;
break;
}
if (pid->cache->cached_frames == NULL)
continue;
gpuPushMatrix();
gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
gpuScale2f(1.0, cache_draw_height);
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
col[3] = 0.1;
break;
case PTCACHE_TYPE_PARTICLES:
col[0] = 1.0; col[1] = 0.1; col[2] = 0.02;
col[3] = 0.1;
break;
case PTCACHE_TYPE_CLOTH:
col[0] = 0.1; col[1] = 0.1; col[2] = 0.75;
col[3] = 0.1;
break;
case PTCACHE_TYPE_SMOKE_DOMAIN:
case PTCACHE_TYPE_SMOKE_HIGHRES:
col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
col[3] = 0.1;
break;
case PTCACHE_TYPE_DYNAMICPAINT:
col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
col[3] = 0.1;
break;
case PTCACHE_TYPE_RIGIDBODY:
col[0] = 1.0; col[1] = 0.6; col[2] = 0.0;
col[3] = 0.1;
break;
default:
col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
col[3] = 0.1;
BLI_assert(0);
break;
}
const int sta = pid->cache->startframe, end = pid->cache->endframe;
const int len = (end - sta + 1) * 6;
glEnable(GL_BLEND);
immUniformColor4fv(col);
immRectf(pos, (float)sta, 0.0, (float)end, 1.0);
col[3] = 0.4f;
if (pid->cache->flag & PTCACHE_BAKED) {
col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
}
else if (pid->cache->flag & PTCACHE_OUTDATED) {
col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
}
immUniformColor4fv(col);
if (len > 0) {
immBeginAtMost(GWN_PRIM_TRIS, len);
/* draw a quad for each cached frame */
for (int i = sta; i <= end; i++) {
if (pid->cache->cached_frames[i - sta]) {
immVertex2f(pos, (float)i - 0.5f, 0.0f);
immVertex2f(pos, (float)i - 0.5f, 1.0f);
immVertex2f(pos, (float)i + 0.5f, 1.0f);
immVertex2f(pos, (float)i - 0.5f, 0.0f);
immVertex2f(pos, (float)i + 0.5f, 1.0f);
immVertex2f(pos, (float)i + 0.5f, 0.0f);
}
}
immEnd();
}
glDisable(GL_BLEND);
gpuPopMatrix();
yoffs += cache_draw_height;
}
immUnbindProgram();
BLI_freelistN(&pidlist);
}
/* ************************************************************************* */

View File

@@ -33,6 +33,8 @@
struct bContext;
struct bAnimContext;
struct Scene;
struct Object;
struct SpaceAction;
struct ScrArea;
struct ARegion;
@@ -54,6 +56,8 @@ void ACTION_OT_properties(struct wmOperatorType *ot);
void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar);
void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar);
void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct Scene *scene);
/* ***************************************** */
/* action_select.c */

View File

@@ -170,7 +170,14 @@ static void action_free(SpaceLink *UNUSED(sl))
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
SpaceAction *saction = sa->spacedata.first;
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
/* enable all cache display */
saction->cache_display |= TIME_CACHE_DISPLAY;
saction->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
saction->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
saction->cache_display |= TIME_CACHE_RIGIDBODY;
}
static SpaceLink *action_duplicate(SpaceLink *sl)
@@ -238,7 +245,13 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
ED_markers_draw(C, flag);
/* caches */
if (saction->mode == SACTCONT_TIMELINE) {
timeline_draw_cache(saction, ac.obact, ac.scene);
}
/* preview range */
// XXX: we should always draw the range
UI_view2d_view_ortho(v2d);
ANIM_draw_previewrange(C, v2d, 0);

View File

@@ -680,6 +680,9 @@ typedef struct SpaceAction {
char mode, autosnap; /* mode: editing context; autosnap: automatic keyframe snapping mode */
short flag; /* flag: bitmapped settings; */
float timeslide; /* for Time-Slide transform mode drawing - current frame? */
int cache_display; /* (eTimeline_Cache_Flag) */
int pad;
} SpaceAction;
/* SpaceAction flag */
@@ -744,6 +747,17 @@ typedef enum eAnimEdit_AutoSnap {
SACTSNAP_TSTEP = 5
} eAnimEdit_AutoSnap;
/* SAction->cache_display */
typedef enum eTimeline_Cache_Flag {
TIME_CACHE_DISPLAY = (1 << 0),
TIME_CACHE_SOFTBODY = (1 << 1),
TIME_CACHE_PARTICLES = (1 << 2),
TIME_CACHE_CLOTH = (1 << 3),
TIME_CACHE_SMOKE = (1 << 4),
TIME_CACHE_DYNAMICPAINT = (1 << 5),
TIME_CACHE_RIGIDBODY = (1 << 6),
} eTimeline_Cache_Flag;
/* ************************************************ */
/* Legacy Data */

View File

@@ -524,16 +524,6 @@ typedef enum eScreen_Redraws_Flag {
TIME_FOLLOW = (1 << 15),
} eScreen_Redraws_Flag;
/* time->cache */
typedef enum eTimeline_Cache_Flag {
TIME_CACHE_DISPLAY = (1 << 0),
TIME_CACHE_SOFTBODY = (1 << 1),
TIME_CACHE_PARTICLES = (1 << 2),
TIME_CACHE_CLOTH = (1 << 3),
TIME_CACHE_SMOKE = (1 << 4),
TIME_CACHE_DYNAMICPAINT = (1 << 5),
TIME_CACHE_RIGIDBODY = (1 << 6),
} eTimeline_Cache_Flag;
/* Sequence Editor ======================================= */

View File

@@ -3271,6 +3271,42 @@ static void rna_def_space_dopesheet(BlenderRNA *brna)
RNA_def_property_enum_items(prop, autosnap_items);
RNA_def_property_ui_text(prop, "Auto Snap", "Automatic time snapping settings for transformations");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL);
/* displaying cache status */
prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY);
RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY);
RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES);
RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH);
RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE);
RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT);
RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_rigidbody", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_RIGIDBODY);
RNA_def_property_ui_text(prop, "Rigid Body", "Show the active object's Rigid Body cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
}
static void rna_def_space_graph(BlenderRNA *brna)