Skip to content

Editor terrain integration#67

Open
tippesi wants to merge 156 commits intomasterfrom
feature/editor-terrain-integration
Open

Editor terrain integration#67
tippesi wants to merge 156 commits intomasterfrom
feature/editor-terrain-integration

Conversation

@tippesi
Copy link
Copy Markdown
Owner

@tippesi tippesi commented Nov 6, 2024

No description provided.

@tippesi tippesi marked this pull request as ready for review April 4, 2026 12:08
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7efafe4f37

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +344 to +345
else if (heightMapSelection && !heightMapImage->HasData()) {
Notifications::Push({ "No heightmap loaded!", vec3(1.0f, 0.0f, 0.0f) });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard null height map before generate check

When heightMapSelection is non-zero and no image has been loaded yet (for example right after switching to "Load file"/"Use existing terrain" before the async update finishes), this branch dereferences heightMapImage unconditionally and can crash the editor. The condition should check that heightMapImage is non-null before calling HasData().

Useful? React with 👍 / 👎.

Comment on lines +121 to +123
p.materials.emplace_back(
FileImporter::ImportFile<Material>(m["material"]), m["color"]
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Skip missing material keys during terrain generator load

Deserialization assumes every entry in materials has a material field, but serialization intentionally omits that key for invalid handles; this makes loading fail with an exception after a user clears a material slot and saves settings. The loader needs to tolerate entries that only contain color (or filter them out) instead of unconditionally indexing m["material"].

Useful? React with 👍 / 👎.

Comment on lines +664 to +666
for (auto mat : materials) {
if (mat.first == selectedMaterial) {
pair = mat;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid reading mutable material list from preview worker

The preview generation lambda runs on a background job but reads materials/selectedMaterial through this; the UI thread can modify materials via add/delete actions while the job is running, which is an unsynchronized std::vector access and can lead to intermittent crashes or corrupted preview output. Capture a snapshot of the material state for the job instead of accessing shared mutable members.

Useful? React with 👍 / 👎.

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 7, 2026

Not up to standards ⛔

🔴 Issues 3 critical · 1 high

Alerts:
⚠ 4 issues (≤ 0 issues of at least minor severity)

Results:
4 new issues

Category Results
ErrorProne 1 high
Security 3 critical

View in Codacy

🟢 Metrics 279 complexity · 54 duplication

Metric Results
Complexity 279
Duplication 54

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@tippesi
Copy link
Copy Markdown
Owner Author

tippesi commented Apr 7, 2026

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b48800b2f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

else if (!selectedMaterial.IsLoaded() && !advanced) {
Notifications::Push({ "At least one material is required!", vec3(1.0f, 0.0f, 0.0f) });
}
else if (heightMapSelection && !heightMapImage->HasData()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard height map pointer before checking HasData

This validation path dereferences heightMapImage whenever heightMapSelection is non-zero, but heightMapImage can still be null (for example, selecting "Load file" without choosing a file, or before async terrain-map extraction finishes). Pressing Generate in that state will crash instead of showing the intended warning. Check the pointer first (e.g. !heightMapImage || !heightMapImage->HasData()).

Useful? React with 👍 / 👎.

Comment on lines +121 to +123
p.materials.emplace_back(
FileImporter::ImportFile<Material>(m["material"]), m["color"]
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle missing material keys when deserializing generator state

to_json writes material entries without a material field when the slot is empty, but this deserializer unconditionally reads m["material"]. If the user saved terrain-generator settings with an unassigned material slot, loading throws during scene-window restore and breaks config deserialization. Guard for missing keys and preserve empty slots instead of forcing import.

Useful? React with 👍 / 👎.

Comment on lines +159 to +163
else if (!editingMode && LoDDistances.size()) {
// If we are here it means we have exited editing mode
for (int32_t i = 0; i < terrain->LoDCount; i++) {
terrain->SetLoDDistance(i, LoDDistances[i]);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Clear cached LoD distances after restoring edit mode

When editing mode is turned off, this branch restores distances from LoDDistances but never clears the cache, so it keeps running every frame and can index past the vector if the user later switches to a terrain with more LoDs than were cached. That creates an out-of-bounds read/write path and applies stale LoD values to unrelated terrains.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants