-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial support for Terrain SmoothGrid data #444
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer we keep the naming scheme intact and name the spec file for SmoothGrid
to be smooth-grid.md
.
Otherwise, I've left my comments and questions for the spec file.
further code commits are paused until structure is reviewed so I don't add the deserializer and have to immediately rewrite it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'd say that this is a good start to an encoder. The comments up above are more focused on the actual code than things like code structure.
Let's rename the terrain.rs
module to smooth_grid.rs
. I'd also like it if the TerrainSerializer
trait could be killed off, since I don't think it adds anything. The encode
and decode
methods could be under the same impl
blocks as the rest of the methods.
Architecturally I have some things I'd like to change but they involve files outside of this PR so I won't force them onto you.. Stuff like moving smooth_grid
and material_colors
into a submodule named terrain
and having them share a Material
enum, as an example. If you want to make those changes you're welcome to but otherwise I'll do it after this is merged.
rbx_types/src/terrain.rs
Outdated
x: i.x as i32, | ||
y: i.y as i32, | ||
z: i.z as i32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really all that rigorous. I don't know if we should expose this without actually checking if the f32
is a valid i32
. At the same time though, that's a hard thing to check, so maybe it's fine.
We should for sure document how it converts it though. Something like "naively converts the components to be i32
s" would at least make it not surprising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the truncation is actually desirable behavior imo, supposed to be whole number and rounding down makes the most sense. or could remove this conversion entirely and force you to know exactly what you're doing
rbx_types/src/terrain.rs
Outdated
terr.write_chunk(&ChunkCoordinates::new(1, 0, 0), chunk.clone()); | ||
|
||
let encoded = base64::encode(terr.encode()); | ||
println!("{}", encoded); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...This test doesn't actually do anything. Can we make it panic if the output isn't identical to something Roblox emitted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is solely for development testing purposes while i was making the encoder so I could put it in place files and hence shouldn't make it out of the draft PR stage
i could give this a shot but I was mainly wondering how the enum should be structured with it being like this? the easiest way would be to just put it in order but you'd have to include air and some other non-colorable materials i think and then implement an error for them?? |
for this |
There's a few ways I can imagine this working. The first is that we just have a Another option is to just say "to hell with it" and have multiple The final option I can see is that we have a centralized I'm inclined to go with the first option since it's the easiest and have the least obstructive UX possible. Moving us to a central In terms of actual implementation, I imagine that each Terrain would have its own internal variant that it used that it just tried to convert into from the central |
Can't wait for Ken for the rest of our days, so I'm gonna go ahead and say go for the plan I gave above with moving us to a central |
DISCLAIMER: THIS IS MY FIRST ACTUAL PROJECT IN RUST. Terrible code will bleach your eyes!
Because of that, this PR also has edits by maintainers on.
This PR adds support for serialization and deserialization to
rbx-types
for theTerrain
objectSmoothGrid
property data.This fully permits the creation of external tooling for modification and generation of smooth terrain data, as Roblox Studio, along with RCCService (presumably) generate the additionally-required PhysicsGrid data at runtime/publish-time.
As a bonus, no reverse engineering of the client had to be done here; just a lot of comparing outputs with ImHex peddled by this article.
https://zeux.io/2017/03/27/voxel-terrain-storage/
Rendered spec.