diff --git a/source/blender/editors/space_action/action_draw.cc b/source/blender/editors/space_action/action_draw.cc index 9bdb9ca8b08..dc2aacf8e9d 100644 --- a/source/blender/editors/space_action/action_draw.cc +++ b/source/blender/editors/space_action/action_draw.cc @@ -577,17 +577,16 @@ static void timeline_cache_color_get(PTCacheID *pid, float color[4]) } } -static void timeline_cache_modify_color_based_on_state(PointCache *cache, float color[4]) +static void timeline_cache_modify_color_based_on_state(PointCache *cache, float color[4], float color_state[4]) { if (cache->flag & PTCACHE_BAKED) { - color[0] -= 0.4f; - color[1] -= 0.4f; - color[2] -= 0.4f; + add_v3_fl(color, -0.4f); + copy_v4_v4(color_state, color); } else if (cache->flag & PTCACHE_OUTDATED) { - color[0] += 0.4f; - color[1] += 0.4f; - color[2] += 0.4f; + add_v3_fl(color, 0.4f); + copy_v4_v4(color_state, color); + mul_v3_fl(color_state, 0.5f); } } @@ -669,12 +668,20 @@ static void timeline_cache_draw_single(PTCacheID *pid, float y_offset, float hei float color[4]; timeline_cache_color_get(pid, color); - immUniformColor4fv(color); + /* Color the entire row to mark it as cache line. */ + immUniform4fv("color1", color); + immUniform4fv("color2", color); immRectf(pos_id, float(pid->cache->startframe), 0.0, float(pid->cache->endframe), 1.0); + /* Now draw the area for the cached frames on top. */ color[3] = 0.4f; - timeline_cache_modify_color_based_on_state(pid->cache, color); - immUniformColor4fv(color); + float color_state[4]; + copy_v4_v4(color_state, color); + + timeline_cache_modify_color_based_on_state(pid->cache, color, color_state); + + immUniform4fv("color1", color); + immUniform4fv("color2", color_state); timeline_cache_draw_cached_segments(pid->cache, pos_id); @@ -694,22 +701,28 @@ static void timeline_cache_draw_simulation_nodes( float color[4]; UI_GetThemeColor4fv(TH_SIMULATED_FRAMES, color); + + float color_state[4]; + copy_v4_v4(color_state, color); + switch (cache.cache_state()) { case blender::bke::sim::CacheState::Invalid: { - color[3] = 0.4f; + color[3] = color_state[3] = 0.7f; + mul_v3_fl(color_state, 0.5f); break; } case blender::bke::sim::CacheState::Valid: { - color[3] = 0.7f; + color[3] = color_state[3] = 0.7f; break; } case blender::bke::sim::CacheState::Baked: { - color[3] = 1.0f; + color[3] = color_state[3] = 1.0f; break; } } - immUniformColor4fv(color); + immUniform4fv("color1", color); + immUniform4fv("color2", color_state); const int start_frame = scene.r.sfra; const int end_frame = scene.r.efra; @@ -738,13 +751,17 @@ void timeline_draw_cache(const SpaceAction *saction, const Object *ob, const Sce uint pos_id = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); GPU_blend(GPU_BLEND_ALPHA); /* Iterate over point-caches on the active object, and draw each one's range. */ float y_offset = 0.0f; const float cache_draw_height = 4.0f * UI_SCALE_FAC * U.pixelsize; + + immUniform1i("size1", cache_draw_height * 2.0f); + immUniform1i("size2", cache_draw_height); + LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) { if (timeline_cache_is_hidden_by_setting(saction, pid)) { continue;