TzuChieh / Photon-v2

A program that takes photographs of a virtual world.
https://tzuchieh.github.io/Photon-v2-site/engine_docs/v2.0.0-beta/Photon/html/index.html
MIT License
84 stars 5 forks source link

Notes on preserving comments, data packet names, formatting of .p2 files #86

Open TzuChieh opened 10 months ago

TzuChieh commented 10 months ago

Background

The thing is that, .p2 can be used for rendering (or transport), or for generating .pds file and edit in the editor. For rendering, we only need to keep the rendered scene the same, and can even optimize the format a bit (e.g., shorter names, better separation of files to enhance parallelism). For editing, we may want to keep at least some information such as packet names and comments. So this pretty much comes down to the following conclusion:

Problems

However, named packets can be expanded multiple times, is it even possible to restore their original structure? Kind of like trying to work out the original macro call sequence from expanded result. Also, data read in may already be modified, trying to store them as they were loaded does not make sense (e.g., two resource uses the same named data packet, but both struct objects are modified differently, no longer can share a named packet).

Current Implementation

Named packets are treated as macros for writing scene file--they are parsed, expanded, and discarded once the scene loading process is done. When named packets have name collision, the newer one will overwrite the old one and emit an overwriting warning. One exception is that name with a '$' prefix means it is "cached" and can be overwritten without warning.

In the future we may allow named packet "resources", with '@' prefix to signify that they are tracked and saved. We will see if these updates are required.