diff options
author | David Walter Seikel | 2014-05-24 17:02:30 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-24 17:02:30 +1000 |
commit | 58141bf77c37757811420f74db13a9f2e9db9e08 (patch) | |
tree | 4ce1fc717fe77e62d731289db7456de7f7704877 | |
parent | More notes about stuffs directory structure. (diff) | |
download | SledjHamr-58141bf77c37757811420f74db13a9f2e9db9e08.zip SledjHamr-58141bf77c37757811420f74db13a9f2e9db9e08.tar.gz SledjHamr-58141bf77c37757811420f74db13a9f2e9db9e08.tar.bz2 SledjHamr-58141bf77c37757811420f74db13a9f2e9db9e08.tar.xz |
Move the latest thoughts about directory structure into the love docs, add more, and clean them up.
-rw-r--r-- | docs/love.txt | 184 | ||||
-rw-r--r-- | src/libraries/love.h | 115 |
2 files changed, 184 insertions, 115 deletions
diff --git a/docs/love.txt b/docs/love.txt index c704aba..5e9a981 100644 --- a/docs/love.txt +++ b/docs/love.txt | |||
@@ -65,3 +65,187 @@ pump in the love server. Lspace just needs read access, and just | |||
65 | serves the current state of the world. Love server persists to disk | 65 | serves the current state of the world. Love server persists to disk |
66 | when it's ready to, though the shared memory can just be memory mapped | 66 | when it's ready to, though the shared memory can just be memory mapped |
67 | files. | 67 | files. |
68 | |||
69 | |||
70 | Thoughts about directory structure. | ||
71 | ======================================== | ||
72 | |||
73 | A major goal is to have the disk structure of a sim (and inventory) be | ||
74 | decently human readable. The assets should be stored as normal files of | ||
75 | the appropriate type, so that they can be edited with normal editing | ||
76 | software like blender, gimp, a text editor, etc. Oter goals include not | ||
77 | duplicating assets, and making it easy to move assets around. | ||
78 | |||
79 | Names. | ||
80 | ------ | ||
81 | |||
82 | A major LL created problem is that in world objects can have the same | ||
83 | name, though stuff in an objects inventory is forced to have unique | ||
84 | names by automatically adding numbers to the names. In inventory you | ||
85 | can have stuff with the same name to. The same named objects don't have | ||
86 | to be the same object, they can be completely different. A simple | ||
87 | object name to file name matching, with directories for contents, just | ||
88 | wont work. Need to munge the names anyway. | ||
89 | |||
90 | All name munging should produce names that are compatible with various | ||
91 | OS file systems, compatible with URLs, add "_123" numbers at the end for | ||
92 | duplicate names in the same directory, and auto add a file extension if | ||
93 | one is missing. Probably should check the file type if there IS a file | ||
94 | extension. | ||
95 | |||
96 | Links and URLs. | ||
97 | --------------- | ||
98 | |||
99 | Any asset file could be a stuffs.lnk file, which holds a relative path | ||
100 | name or full URL pointing to the real asset. An external lspace server | ||
101 | would return the .omg file when the stuffs URL is requested, or an | ||
102 | actual asset file when those are requested. | ||
103 | |||
104 | Would have to do copy on write for editing and other state changes, not | ||
105 | including script state changes. | ||
106 | |||
107 | Probably need to store other info in the .lnk file if it's a URL, SHA-1 | ||
108 | of the original file, other web cache info. Which starts to encroach on | ||
109 | web proxy / cache territory, which we may not want to do, since we want | ||
110 | to use real ones instead of crappy LL cache. | ||
111 | |||
112 | Actually, file names / URLs in .omg files would mostly be relative to | ||
113 | the file name / URL of the sim, and all the way down, so relative to the | ||
114 | directory things are in. It's up to the client to keep track of where | ||
115 | they are and build appropriate full URL / full path file names. | ||
116 | |||
117 | UUIDS. | ||
118 | ------ | ||
119 | |||
120 | Original LL UUIDs are the usual 36 byte string representing 32 lower | ||
121 | case hex characters and some dashes, encoding a 128 bit number. I was | ||
122 | inspired by git using SHA-1 hashes for content addressable assets. | ||
123 | SHA-1 hashes are 40 character hex codes representing 160 bit numbers | ||
124 | that are calculated based on the content. So the same content will give | ||
125 | the same SHA-1 hash. Git has proved that you only need the first digits | ||
126 | of the SHA-1 hash to ensure uniqueness, so it's feasable to use only the | ||
127 | first 128 bits of SHA-1 hashes to squeeze it into a UUID for the | ||
128 | purposes of uniquely identifying assets. Precisely what git does. This | ||
129 | means it could be backwards compatible with LL's use of UUIDs. | ||
130 | |||
131 | Since the SHA-1 code of identical files is the same, we could use this | ||
132 | to reduce duplicated large assets that never change, like textures and | ||
133 | sounds. This will be a big win. | ||
134 | |||
135 | I think we can get away with not storing SHA-1 hashes permanently, just | ||
136 | use them for in memory references, but cache them to disk separately. | ||
137 | The caches can be recreated at any time, since the SHA-1 hashes can be | ||
138 | calculated based on the data in the assets. So no UUIDs stored in .omg | ||
139 | files, just relative file / URL friendly names. The UUID / SHA-1 hashes | ||
140 | are mostly for keeping in memory as keys to stuff, coz they can shrink | ||
141 | down to a long long 128 bit integer. | ||
142 | |||
143 | Each asset file, whether texture, script, mesh, text file, etc, comes | ||
144 | with a matching .sha1 file that holds the SHA-1 hash of that file. .lnk | ||
145 | files get hashed to, so that each copy of a linked stuffs gets it's own | ||
146 | SHA-1 hash, but in this case the "content" is the relative path name. | ||
147 | The .sha1 files of the real asset .lnk files point to can be found in | ||
148 | the same place the real asset file is. | ||
149 | |||
150 | There will be a .sha1 directory full of files with the SHA-1 hashes as | ||
151 | part of the name, and the rest being similar to a .lnk file, a path to | ||
152 | the asset or .lnk file. Would save love server needing to keep that all | ||
153 | in memory all the time. | ||
154 | |||
155 | If the file system date stamp for the asset file is later than the one | ||
156 | for the .sha1 file, then someone edited the file, recreate the .sha1 | ||
157 | files. | ||
158 | |||
159 | All the SHA-1 hashes can be recreated at any time, using file system | ||
160 | date stamps to tell if one is stale. They are only used internally to a | ||
161 | running system, to pass small identifiers around, and to fake LL UUIDs | ||
162 | for LSL scripts. When a SHA-1 hash is calculated for a new asset, it | ||
163 | gets stored in the .sha1, but if it already exists in .sha1, then the | ||
164 | asset is replaced by that sha1.lnk file, thus automatically | ||
165 | deduplicating assets. | ||
166 | |||
167 | On disk structure. | ||
168 | ------------------ | ||
169 | |||
170 | "some sim name" -> some%20sim%20name/index.omg | ||
171 | list of stuffs rezzed in the sim | ||
172 | stuffs position, orientation, and size | ||
173 | relative file / URL name pointing to the stuffs | ||
174 | no need for the in world name, those interested in that will likely grab the stuffs.omg file anyway | ||
175 | |||
176 | "a stuffs" -> a%20stuffs.omg | ||
177 | in world name, description | ||
178 | list of stuffs similar to the sim index.omg, only this is for the various meshes that make up this stuffs. | ||
179 | stuffs position, orientation, and size | ||
180 | relative file / URL name pointing to the mesh and textures | ||
181 | extra info for each material | ||
182 | |||
183 | a%20stuffs/ directory | ||
184 | files that are the contents of this stuffs | ||
185 | could be .lnk files | ||
186 | .sha1 files | ||
187 | |||
188 | a%20stuffs/index.omg | ||
189 | used to be a list of content file names, type, and UUID | ||
190 | file names are right there in the directory | ||
191 | UUID ala SHA-1 can now be calculated based on those files | ||
192 | and stored in a asset.sha1 file | ||
193 | type can use the magic/file/MIME system to identify file types | ||
194 | can get rid of this file, though maybe have it in a .types directory, | ||
195 | coz we would want to cache the file type | ||
196 | or just use a poor mans magic/file/MIME thingy based on file extension, | ||
197 | since we only have a small number of file types | ||
198 | note cards should have a .txt, scripts a .lsl or .lua | ||
199 | |||
200 | People could even be free to use their own organising directory | ||
201 | structure. A directory for ground level, and one for each sky box for | ||
202 | instance. Relative paths inside .omg files sorts that all out. | ||
203 | |||
204 | A sims index.omg file might be constantly updated for busy sims. Could | ||
205 | generate it on the fly by the lspace server, based on the actual | ||
206 | contents of the sim directory. Alternative lspace servers could just | ||
207 | use a CMS system for all of this anyway. They would still use the same | ||
208 | structure for URLs and .omg files. | ||
209 | |||
210 | Avatars. | ||
211 | -------- | ||
212 | |||
213 | Storing avatars in this way isn't such a good idea? Avatars could have | ||
214 | their own avatar.omg dealing with shape, skin, clothes, attachments, | ||
215 | etc. But instead of a client asking for a list, avatar arrivals and | ||
216 | departures are driven by love. Though try to keep avatars as "just | ||
217 | ordinary object, but with a person controlling it". Still, they move | ||
218 | around a lot. | ||
219 | |||
220 | Avatar.omg would live on the users hard drive, but sent to the love | ||
221 | server on login, and after any change. | ||
222 | |||
223 | Misc. | ||
224 | ----- | ||
225 | |||
226 | Right now I'm using Lua style .omg files, but eet would be a better | ||
227 | choice I think. Saves having to write a Lua table to C structure | ||
228 | system, which eet already has, sorta. Lua tables are at least more | ||
229 | readable while I consider the design, but likely use eet instead when I | ||
230 | have to write code to read the suckers. .omg files are managed by the | ||
231 | love server, so fiddling with them is an expert thing anyway. | ||
232 | |||
233 | Should have a tool to validate a sims files and recreate te caches. | ||
234 | |||
235 | Remaining issues. | ||
236 | ----------------- | ||
237 | |||
238 | Owner / group UUID might be better dealt with elsewhere? Coz links. | ||
239 | Also, we wont replicate the LL user / group stuff exactly, but morph | ||
240 | into more standardised variations. Jabber users, jabber group rosters, | ||
241 | OS users, web site users, etc. So just provide an abstraction, and an | ||
242 | example or two. | ||
243 | |||
244 | The asset files, plus things like compiled script binaries and temporaries | ||
245 | might be better to move compiled scripts and generated Lua source to the LuaSL server's own private store? | ||
246 | LuaSL needs to assign UUIDs to compiled script binaries, so it knows which running script is which | ||
247 | coz there might be lots of copies of scripts | ||
248 | on the other hand, each copy is uniquely named inside some objects contents, | ||
249 | even if it's a link, | ||
250 | so the UUID of the stuffs plus the UUID within the stuffs contents, for this copy / link of the script should suffice? | ||
251 | |||
diff --git a/src/libraries/love.h b/src/libraries/love.h index f951a89..f75d5e7 100644 --- a/src/libraries/love.h +++ b/src/libraries/love.h | |||
@@ -188,119 +188,4 @@ Extantz client starts up | |||
188 | */ | 188 | */ |
189 | 189 | ||
190 | 190 | ||
191 | /* More thoughts about directory structure | ||
192 | |||
193 | A major goal is to have the disk structure of a sim (and inventory) be | ||
194 | decently human readable. The assets should be stored as normal files of | ||
195 | the appropriate type, so that they can be edited with normal editing | ||
196 | software like blender, gimp, a text editor, etc. | ||
197 | |||
198 | A major LL created problem is that in world objects can have the same | ||
199 | name, though stuff in an objects inventory is forced to have unique | ||
200 | names by automatically adding numbers to the names. In inventory you | ||
201 | can have stuff with the same name to. The same named objects don't have | ||
202 | to be the same object, they can be completely different. A simple | ||
203 | object name to file name matching, with directories for contents, just | ||
204 | wont work. Perhaps the automatic adding of numbers thing would be best? | ||
205 | All names have to be coerced into operating system friendly names | ||
206 | anyway, so there still needs to be some sort of mapping between objects | ||
207 | and their names. Not to mention URL escaping for names to. Try to | ||
208 | combine both. | ||
209 | |||
210 | Should have a tool to validate a sims files. | ||
211 | |||
212 | Sooo, directory structure of a sim - | ||
213 | |||
214 | "sim name" -> sim%20name | ||
215 | index.omg | ||
216 | lists objects in the sim, with details about UUID, position, orientation, and size | ||
217 | maps in world name <-> file name / URL name | ||
218 | actually use file:// style URLs, so that we can pass them to clients, | ||
219 | and have the posibility of pointing to assets on some other lspace server | ||
220 | the name is a duplicate of what's inside the objects .omg file | ||
221 | Should try to keep these in sync automaticallly | ||
222 | sim index.omg files are managed by the love server, | ||
223 | so fiddling with them outside is an expert thing to do | ||
224 | "object name" -> object%20name.omg and a directory called object%20name | ||
225 | this file name could also be munged if there are objects with duplicate names | ||
226 | an external lspace server would return the .omg file when the objects URL is requested | ||
227 | .omg file contains file names / URLs of other assets like actual mesh files and textures | ||
228 | also UUID, in world name, description, owner UUID. | ||
229 | owner UUID might be better dealt with elsewhere? | ||
230 | coz links | ||
231 | directory contains the contents of the object | ||
232 | index.omg | ||
233 | lists the stuffs in the objects contents, with UUID and type for each | ||
234 | maps in world name <-> file name / URL name | ||
235 | the asset files, plus things like compiled script binaries and temporaries | ||
236 | might be better to move compiled scripts and generated Lua source to the LuaSL server's own private store? | ||
237 | LuaSL needs to assign UUIDs to compiled script binaries, so it knows which running script is which | ||
238 | coz there might be lots of copies of scripts | ||
239 | on the other hand, each copy is uniquely named inside some objects contents, | ||
240 | even if it's a link, | ||
241 | so the UUID of the stuffs plus the UUID within the stuffs contents, for this copy / link of the script should suffice? | ||
242 | except links | ||
243 | |||
244 | Yes, this means that files and directories can be links in the case of duplicate assets. | ||
245 | Though the UUIDs inside .omg files would have to be unique? | ||
246 | Only for script binaries I think. | ||
247 | Would have to do copy on write for editing and other state changes, not including script state changes. | ||
248 | So links to object .omg files would all have the same UUID. | ||
249 | Which works well with using sha-1 content addressable assets. B-) | ||
250 | |||
251 | People could even be free to use their own organising directory | ||
252 | structure. A directory for ground level, and one for each sky box for | ||
253 | instance. Relative paths inside .omg files sorts that all out. | ||
254 | |||
255 | Actually, file names / URLs in .omg files would mostly be relative to | ||
256 | the file name / URL of the sim, and all the way down, so relative to the | ||
257 | directory things are in. It's up to the client to keep track of where | ||
258 | they are and build appropriate full URL / full path file names. | ||
259 | |||
260 | A sims index.omg file might be constantly updated for busy sims. | ||
261 | Could generate it on the fly by the lspace server, based on the actual contents of the sim directory. | ||
262 | Alternative lspace servers could just use a CMS system for all of this anyway. | ||
263 | They would still use the same structure for URLs and .omg files. | ||
264 | |||
265 | Storing avatars in this way isn't such a good idea? | ||
266 | Avatars could have their own index.omg dealing with shape, skin, clothes, attachments, etc. | ||
267 | But instead of client asking for a list, avatar arrivals and departures are driven by love. | ||
268 | Though try to keep avatars as "just ordinary object, but with a person controlling it". | ||
269 | Still, they move around a lot. | ||
270 | |||
271 | Right now I'm using Lua style .omg files, but eet would be a better | ||
272 | choice I think. Saves having to write a Lua table to C structure | ||
273 | system, which eet already has, sorta. Lua tables are at least more | ||
274 | readable while I consider the design, but likely use eet instead when I | ||
275 | have to write code to read the suckers. | ||
276 | |||
277 | Might be useful to have a UUID -> asset file .cache directory, or | ||
278 | something similar? Could save love server needing to keep that all in | ||
279 | memory all the time. Plus, an issue with using sha-1 UUIDs and keeping | ||
280 | them inside the .omg files is that this changes the sha-1 hash. Should | ||
281 | think about keeping uuid's outside of them. Perhaps a .sha1 file along | ||
282 | side each .omg file and asset file? Don't bother with links, if an | ||
283 | asset is a link, just look for the .sha1 file where the real file is. | ||
284 | The UUIDs are mostly for keeping in memory as keys to stuff, coz they | ||
285 | can shrink down to a long. On the other hand, duplicated objects still | ||
286 | need their own UUIDs to refer to each copy / link. Sha-1 the relative | ||
287 | path to the link? It all gets trickier when assets are on different | ||
288 | lspace servers, not to mention some OSes don't support links very well, | ||
289 | or at all. | ||
290 | |||
291 | objectName.omg + objectName.sha1 In each of these cases, the .sha1 file is the sha1 sum of the file it goes with, not of the file it points to. | ||
292 | objectName.lnk + objectName.sha1 .lnk is a relative file name to objectName.omg | ||
293 | objectName.url + objectName.sha1 .url is a URL to a the .omg on a different server | ||
294 | Probably need to store other info in the .url file, sha1 of the original file, other web cache info. | ||
295 | Which starts to encroach on web proxy / cache territory, which we may not want to do, | ||
296 | since we want to use real ones instead of crappy LL cache. | ||
297 | |||
298 | .cache | ||
299 | sha1 as file names of .lnk or .url files. | ||
300 | |||
301 | If the file system date stamps are different, then someone edited the file, recreate the sha1 files. | ||
302 | Which implies that lengthy sha1 calculations need to touch the file once done. | ||
303 | |||
304 | */ | ||
305 | |||
306 | #endif | 191 | #endif |