Skip to content

Comments

New terrain generation for the vents#6591

Draft
Patryk26g wants to merge 20 commits intomasterfrom
new_terrains
Draft

New terrain generation for the vents#6591
Patryk26g wants to merge 20 commits intomasterfrom
new_terrains

Conversation

@Patryk26g
Copy link
Contributor

@Patryk26g Patryk26g commented Dec 20, 2025

This PR does sevelar things:

  • Changes vents terrain generation - now vent-like shapes appear in the vents. The chunks don't have collision shapes, instead one big sphere collision shape appears in the middle instead. Thanks to that the number of collision checks is significantly reduced and microbes won't get stuch on the terrain, they will just slide off,
  • Increases grid cell size so that these vents can spawn more randomly instead of a grid pattern,
  • Significantly reduces area in which chunks spawn
  • Changes spawning logic quite a lot
  • Lowers and increases the background plane a bit, so that chunks can spawn a bit more under the microbe plane (should we stick with that?)

Example terrain:
Screenshot_20251220_133200

Area of terrain generation before:
Screenshot_20251220_133647

And after:
Screenshot_20251220_133430

Left to do:

  • Investingate "unfetched members" prints
  • Do save compatibility

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.

@revolutionary-bot
Copy link

The lead programmer for Thrive is currently on vacation until 2026-01-07. Until then other programmers will try to make pull request reviews, but please be patient if your PR is not getting reviewed.

PRs may be merged after multiple programmers have approved the changes (especially making sure to ensure style guide conformance and gameplay testing are good). If there are no active experienced programmers who can perform merges, PRs may need to wait until the lead programmer is back to be merged.

@Patryk26g
Copy link
Contributor Author

I have tested it with previous saves and it works as intended

@hhyyrylainen
Copy link
Member

Does the terrain area now at least extend as far as the spawn system spawns stuff? Because otherwise a microbe might spawn and then as the player moves a bit it might get dumped under a mountain of spawned terrain.

@hhyyrylainen hhyyrylainen added this to the Release 1.0.1 milestone Dec 20, 2025

public string CollisionResourcePath;

public bool SkipCollisionLoading;
Copy link
Member

@hhyyrylainen hhyyrylainen Dec 20, 2025

Choose a reason for hiding this comment

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

I think it would be clearer to just not set this component for stuff that doesn't want to collide...

Edit: and of course it would be more efficient as well to not create the physics component either for purely visual stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure I tried it and I was getting an error because of it but I'll try

Copy link
Member

Choose a reason for hiding this comment

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

With the new ECS framework, you need to tell it the list of components beforehand, so you'll need a variant of the spawn method that uses a different component list, otherwise it'll blow up. For example for the normal chunks I needed to write quite a complex component list selection algorithm but this should be a simpler case that can be done with a single if branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay thanks, I have created new spawn variant

@Patryk26g
Copy link
Contributor Author

Does the terrain area now at least extend as far as the spawn system spawns stuff? Because otherwise a microbe might spawn and then as the player moves a bit it might get dumped under a mountain of spawned terrain.

When I was messing with the sphere collision radius set to big numbers, if a chunk spawned inside it it would be pushed out of the collision shape, so I guess the same would happen with the microbe. I will test it though.

@hhyyrylainen
Copy link
Member

When I was messing with the sphere collision radius set to big numbers, if a chunk spawned inside it it would be pushed out of the collision shape, so I guess the same would happen with the microbe. I will test it though.

That's usually the case but when there are multiple physics bodies overlapping, it can get permanently stuck. For example cell colonies have a much higher chance of being permanently stuck than single cells. So I imagine cell colonies or multicellular species to be more susceptible to this bug. Which is why I would like the terrain area to be big enough so that terrain already exists before the spawn system triggers for it. This is because I made the spawn system explicitly ask the terrain system that it doesn't try to spawn stuff overlapping terrain (though it uses a fixed radius so it needs a bit improving for multicellular).

@Patryk26g
Copy link
Contributor Author

That's usually the case but when there are multiple physics bodies overlapping, it can get permanently stuck. For example ...
I have tested it with multicellular and didnt notice any issues but I increased the spawning area just to be sure

Copy link
Member

@hhyyrylainen hhyyrylainen left a comment

Choose a reason for hiding this comment

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

I didn't yet read the microbe terrain system changes as the diff shows the entire file as new. But here's some overall comments about the other parts of the architecture and how I kind of don't really like how many parts of the system have been dismantled.

Comment on lines 191 to 192
public const float TERRAIN_GRID_SIZE_X = 330;
public const float TERRAIN_GRID_SIZE_Z = 315;
Copy link
Member

Choose a reason for hiding this comment

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

These grid sizes seem a bit specific... Any reason why not a round number like 300?

Copy link
Contributor Author

@Patryk26g Patryk26g Jan 10, 2026

Choose a reason for hiding this comment

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

well, when I was messing with it it used to be more rectangular since the screens are wider, so that chunks would spawn further horizontally and less vertically (for example 200x300 but with such low difference now it doesn't make sense to keep it)

Copy link
Member

Choose a reason for hiding this comment

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

That doesn't fully make sense to me because the spawn system spawn radius is a circle, so having more horizontal space doesn't really help with stuck-in-terrain spawns...

Comment on lines +209 to +216
public const int TERRAIN_VENT_SEGMENTS = 6;
public const int TERRAIN_VENT_RINGS_MAX = 5;
public const int TERRAIN_VENT_RINGS_MIN = 2;
public const int TERRAIN_SECOND_VENT_RINGS_MIN_THRESHOLD = 3;
public const float TERRAIN_SECOND_VENT_CHANCE = 0.4f;
public const int TERRAIN_VENT_OVERLAP_MARGIN = 2;
public const int TERRAIN_VENT_RING_HEIGHT_REDUCTION = 10;
public const int TERRAIN_VENT_OUTER_RING_HEIGHT = -27;
Copy link
Member

Choose a reason for hiding this comment

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

I haven't read all the code yet, but my impression is that these would be nice to configure from the JSON.

"PotentialClusters": [
{
"RelativeChance": 1,
"SpawnStrategy": 1,
Copy link
Member

Choose a reason for hiding this comment

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

Please use enum value names here in the JSON so that it is easy to read.

current = true

[node name="BackgroundPlane" parent="." instance=ExtResource("2_yrakl")]
transform = Transform3D(1.1, 0, 0, 0, 1.1, 0, 0, 0, 1.1, 0, 0, -10)
Copy link
Member

Choose a reason for hiding this comment

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

What's this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like I said in the description, I lowered the background image a bit

Copy link
Member

Choose a reason for hiding this comment

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

Ah, okay.
Did you test with the max multicellular zoom out distance to see if the edges of the plane are visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I also increased the size of the background to negate it but I will have to check

Copy link
Member

Choose a reason for hiding this comment

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

Somehow I missed that. Otherwise I would have made sure the size to UV ratio is the same so that the visuals aren't stretched differently than before.

public readonly float Radius;

[JsonProperty]
public readonly Vector3 RelativePosition;
Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing the advanced chunk configuration from the JSON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What was the need to include the relativePosition and Rotation there? It can be configured programatically anyway (and it is done so)

unless we want to also define complex structures using only json. If so, I can revert it

Copy link
Member

Choose a reason for hiding this comment

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

unless we want to also define complex structures using only json. If so, I can revert it

That's exactly it. I wanted the JSON to be used to define complex structures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay that makes sense. But I guess it is okay to have 2 ways to define the terrain shapes? One by having it done programmatically like the vents and the other statically in the json?

Copy link
Member

Choose a reason for hiding this comment

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

I'd say that it would make sense to modify the chunk configuration so that it is either a single chunk or a procedurally generated shape.
Or just flat out not permit the sub-group definitions if the spawn shape is one that is automatically calculated.

/// <summary>
/// Handles terrain spawning shapes logic
/// </summary>
public partial class MicrobeTerrainSystem
Copy link
Member

Choose a reason for hiding this comment

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

Why did you rename the file this system is in but not the class? You should probably revert the file name back. That should also give a more useful diff.

Copy link
Contributor Author

@Patryk26g Patryk26g Jan 10, 2026

Choose a reason for hiding this comment

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

I didn't rename the file, I created second one creating a partial class because in my opinion there was too many lines of code for one file

Copy link
Member

Choose a reason for hiding this comment

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

Partial class files should be named ClassName.PurposeOfPartial.cs so that they are grouped next to each other.

Copy link
Member

Choose a reason for hiding this comment

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

And if renaming back, this file sohuld probably be deleted.

var entity = worldSimulation.CreateEntityDeferred(entityRecorder, TerrainWithCustomCollisionSignature);

Quaternion rotation;
if (chunkConfiguration.RandomizeRotation)
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove the base rotation feature? Devon said that some of the chunks were clearly meant to also rotate horizontally etc. so I don't think that feature makes sense to remove from this base code...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I must have forgot about that...

typeof(MicrobeTerrainChunk), typeof(PredefinedVisuals), typeof(Physics), typeof(PhysicsShapeHolder),
typeof(CollisionShapeLoader), typeof(StaticBodyMarker));

private static readonly Signature TerrainWithCustomCollisionSignature = new(typeof(WorldPosition),
Copy link
Member

Choose a reason for hiding this comment

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

I'm reading this and this looks to be the exact same as the TerrainSignature, so why does this exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't have CollisionShapeLoader

Copy link
Member

Choose a reason for hiding this comment

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

Ah, apparently I'm blind then. Still, I recommend changing the name to TerrainWithoutCollisionSignature for clarity as to what the purpose of this is.

Comment on lines 1146 to 1149
entityRecorder.Set(entity, new PredefinedVisuals
{
VisualIdentifier = VisualResourceIdentifier.None,
});
Copy link
Member

Choose a reason for hiding this comment

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

This is just a waste if this is meant to be just a collision to even have the visual component in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I guess I will need to create another signature for that

@Patryk26g
Copy link
Contributor Author

Patryk26g commented Jan 18, 2026

Still haven't fixed all things so please don't review it yet

@Patryk26g Patryk26g marked this pull request as draft January 18, 2026 18:14
# Conflicts:
#	src/microbe_stage/MicrobeCamera.tscn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants