Conversation
kring
left a comment
There was a problem hiding this comment.
This looks good to me. Just a couple of nitpicky comments.
| ${createPropertyDoc(propertyDefaultValues)} | ||
| enum class ${toPascalCase(propertyName)} { | ||
| ${createEnumPropertyDoc(propertyDefaultValues)} | ||
| class ${enumName} { |
There was a problem hiding this comment.
This is pretty nitpicky, but let's use a struct rather than a class with all public members. Consistent with the other glTF types.
|
|
||
| if (enumDetails.type === "integer") { | ||
| return `${makeIdentifier(enumDetails.description)} = ${ | ||
| return `static const int32_t ${makeIdentifier(enumDetails.description)} = ${ |
There was a problem hiding this comment.
This would be slightly better as a constexpr I think.
| }`; | ||
| } else { | ||
| return makeIdentifier(enumDetails.enum[0]); | ||
| return `inline static const std::string ${makeIdentifier(enumDetails.enum[0])} = \"${enumDetails.enum[0]}\"`; |
There was a problem hiding this comment.
I think this can't be constexpr in C++17, but if it can be it should be too.
This does not compile. It is only the update of the auto-generated classes, without the corresponding updates in the non-auto-generated classes.
This updates the non-auto-generated classes based on the changes of the auto-generated ones.
It was only used in CesiumGltfWriter, and is no longer required after the glTF enum updates
The tests assumed that the enum members are initialized with "the first" enum value, if no explicit default value was given. In the schema, the "type" is only specified in every element of "anyOf" when the type is "integer" (but not when it is "string"). Not sure who to blame here...
Apparently, all implementations are in one file. Not sure where the individual files came from...
|
I have updated the generator to use
The update of the non-auto-generated classes was less of a hassle than I thought. The There's one question about error handling: Files like which are now a which means that the error handling becomes more important. These should at least print an error message (as marked with a few Right now, In order to use
I'm slightly leaning towards the latter. One concern is that it makes Initially, the tests failed, because there are some assumptions about the initial values for the enum members. For example, the I was a bit confused about the role of the files in the |
|
I opened a follow up PR that brings us up-to-date with the latest glTF schema: #351
I was also confused by this. |
|
I don't think CesiumGltf has any business logging, especially not in such a low-level function. Documenting that it returns 0 for an unknown type is sufficient. Then the caller can assert, throw an exception, or log as appropriate. |
|
This looks good to me, let's get it merged for our release tomorrow. |
…GS/cesium-native into gltf-generator-enum-fixes
|
Before this becomes part of a release, it should be tested more thoroughly. I have re-introduced the unit test that I had created in #259 to illustrate the issue. This one passes now. But... this only means that it no longer bails out with an "Unspecified parse error". Further tests will be necessary. Particularly: If there is a B3DM with a glTF with a Unfortunately, we don't have a tileset that uses WebP images. The closest that we have was a single B3DM that was provided in the forum thread https://community.cesium.com/t/problems-with-loading-local-3dtiles-models/12869/20 where this issue came up. As a quick test, I just took https://github.com/CesiumGS/cesium/tree/main/Specs/Data/Cesium3DTiles/Batched/BatchedTextured , changed the (Edit: The crucial point is: We have to test whether the whole thing might crash if it actually encounters real, binary WebP data!) In order to have a real-world test, we need a tileset that actually contains a B3DM with a glTF with a WebP image. And preferably, with the same complexity as the And... sure, I'd fix the merge conflicts... |
|
I tried the But it otherwise loads and displays fine (no textures of course): Before this PR, we got messages like this: And the model didn't display at all. So we could definitely do better on the warning message, but this still a major improvement. |
|
@javagl I'm going to merge this without waiting for a proper test. But if and when you'd like to do that (it's certainly a good idea!) you should be able to get a good test tileset by uploading a simple textured glTF to ion and asking it to produce WebP textures: |


This is supposed to address #258 ,
but ...
... how this relates to #307 has to be sorted out. There are several loose ends to consider, summarized quickly from the tip of my head:
generate-gltf-classesproject has been refactored significantlyschema-gen)mainbranch, the writer classes are written manually)CesiumGltfclasses as they are. It might be possible to solve this quickly, but not without diving deeper into the code (and thus, it would be not "quickly"...).This PR is, roughly speaking, the attempt to do the "smallest modifications" to the original code generator that allow us to write code where the
enums use their underlying type. The results, summarized with some examples here:Old integer enums:
New integer enums:
Old string enums:
New string enums:
The code for the generated Readers is updated accordingly. Some places in the not-auto-generated classes will have to be updated manually - mostly
switchstatements, but a few others. Unfortunately, the code for the current Writers is also not auto-generated, and this may require a bunch of tedious updates that are supposed to be ... overwritten by the auto-generated writers soon. But if this is desired (depending on the priorities), I can tackle that.Finally... I have to link to Lava Flow here.