diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index 7125842f..e2c45d07 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -8305,6 +8305,32 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt) { df_entity_mark_for_deletion(map); } + { + DF_AutoViewRuleMapCache *cache = &df_state->auto_view_rule_cache; + if(cache->arena == 0) + { + cache->arena = arena_alloc(); + } + arena_clear(cache->arena); + cache->slots_count = 1024; + cache->slots = push_array(cache->arena, DF_AutoViewRuleSlot, cache->slots_count); + DF_EntityList maps = df_query_cached_entity_list_with_kind(DF_EntityKind_AutoViewRule); + for(DF_EntityNode *n = maps.first; n != 0; n = n->next) + { + DF_Entity *map = n->entity; + DF_Entity *src = df_entity_child_from_kind(map, DF_EntityKind_Source); + DF_Entity *dst = df_entity_child_from_kind(map, DF_EntityKind_Dest); + String8 type = src->name; + String8 view_rule = dst->name; + U64 hash = df_hash_from_string(type); + U64 slot_idx = hash%cache->slots_count; + DF_AutoViewRuleSlot *slot = &cache->slots[slot_idx]; + DF_AutoViewRuleNode *node = push_array(cache->arena, DF_AutoViewRuleNode, 1); + node->type = push_str8_copy(cache->arena, type); + node->view_rule = push_str8_copy(cache->arena, view_rule); + SLLQueuePush(slot->first, slot->last, node); + } + } }break; //- rjf: general entity operations diff --git a/src/df/core/df_core.h b/src/df/core/df_core.h index c6a3982f..485cc0b9 100644 --- a/src/df/core/df_core.h +++ b/src/df/core/df_core.h @@ -920,6 +920,31 @@ struct DF_EntityListCache DF_EntityList list; }; +//- rjf: auto view rules hash table cache + +typedef struct DF_AutoViewRuleNode DF_AutoViewRuleNode; +struct DF_AutoViewRuleNode +{ + DF_AutoViewRuleNode *next; + String8 type; + String8 view_rule; +}; + +typedef struct DF_AutoViewRuleSlot DF_AutoViewRuleSlot; +struct DF_AutoViewRuleSlot +{ + DF_AutoViewRuleNode *first; + DF_AutoViewRuleNode *last; +}; + +typedef struct DF_AutoViewRuleMapCache DF_AutoViewRuleMapCache; +struct DF_AutoViewRuleMapCache +{ + Arena *arena; + U64 slots_count; + DF_AutoViewRuleSlot *slots; +}; + //- rjf: per-run unwind cache typedef struct DF_RunUnwindCacheNode DF_RunUnwindCacheNode; @@ -1117,8 +1142,7 @@ struct DF_State // rjf: entity query caches U64 kind_alloc_gens[DF_EntityKind_COUNT]; DF_EntityListCache kind_caches[DF_EntityKind_COUNT]; - DF_EntityListCache dbg_info_cache; - DF_EntityListCache bin_file_cache; + DF_AutoViewRuleMapCache auto_view_rule_cache; // rjf: per-run caches U64 unwind_cache_reggen_idx; diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index 643ba0fe..3e34a1b0 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -3950,7 +3950,7 @@ DF_VIEW_UI_FUNCTION_DEF(AutoViewRules) { edit_end = 1; edit_commit = avrs->input_editing; - next_cursor.x = 2; + next_cursor.x = 1; next_cursor.y = map_idx+1; }