Skip to content

Updated to Godot HashMap, HashSet, and Pair types#901

Open
rpgshooter wants to merge 1 commit intoTokisanGames:mainfrom
rpgshooter:updated-Hash-Pair-redefs
Open

Updated to Godot HashMap, HashSet, and Pair types#901
rpgshooter wants to merge 1 commit intoTokisanGames:mainfrom
rpgshooter:updated-Hash-Pair-redefs

Conversation

@rpgshooter
Copy link
Copy Markdown
Contributor

Replace std::unordered_set/map with Godot containers:

Addition to #880

Summary

Replace std::unordered_map and std::unordered_set with Godot's HashMap and HashSet in Terrain3DInstancer
Remove custom hash structs that are no longer needed (Godot's HashMapHasherDefault provides built-in hashing for Vector2i, Vector3, and Pair<F, S>)
This change prepares the codebase for C++20 compatibility

Changes

constants.h
Removed Vector2iHash, PairVector2iIntHash, and Vector3Hash structs
terrain_3d_instancer.h
Replaced <unordered_map> and <unordered_set> includes with Godot templates
Changed type aliases to use HashMap<Vector2i, Pair<RID, RID>> and HashSet<Pair<Vector2i, int>>
terrain_3d_instancer.cpp
Updated API calls: .empty() → .is_empty(), .count() → .has(), .emplace() → .insert()
Changed std::make_pair to Pair<Vector2i, int>
Updated iteration patterns to use KeyValue<K, V> for HashMap and explicit Pair access for HashSet

@TokisanGames TokisanGames added the enhancement New feature or request label Dec 13, 2025
@TokisanGames TokisanGames added this to the 1.2 milestone Dec 13, 2025
@rpgshooter rpgshooter marked this pull request as ready for review March 25, 2026 00:01
@rpgshooter
Copy link
Copy Markdown
Contributor Author

rpgshooter commented Apr 5, 2026

Addendum, the constants.h build error due to not having a .cpp and potential build order would be resolved with this merge. Example of one of the build errors:
src/constants.h:1:1: note: 'std::hash' is defined in header ''; this is probably fixable by adding ""include functional""

@rpgshooter rpgshooter force-pushed the updated-Hash-Pair-redefs branch from b8e83de to 230cf8d Compare April 5, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants