aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-24 17:02:30 +1000
committerDavid Walter Seikel2014-05-24 17:02:30 +1000
commit58141bf77c37757811420f74db13a9f2e9db9e08 (patch)
tree4ce1fc717fe77e62d731289db7456de7f7704877
parentMore notes about stuffs directory structure. (diff)
downloadSledjHamr-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.txt184
-rw-r--r--src/libraries/love.h115
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
65serves the current state of the world. Love server persists to disk 65serves the current state of the world. Love server persists to disk
66when it's ready to, though the shared memory can just be memory mapped 66when it's ready to, though the shared memory can just be memory mapped
67files. 67files.
68
69
70Thoughts about directory structure.
71========================================
72
73A major goal is to have the disk structure of a sim (and inventory) be
74decently human readable. The assets should be stored as normal files of
75the appropriate type, so that they can be edited with normal editing
76software like blender, gimp, a text editor, etc. Oter goals include not
77duplicating assets, and making it easy to move assets around.
78
79Names.
80------
81
82A major LL created problem is that in world objects can have the same
83name, though stuff in an objects inventory is forced to have unique
84names by automatically adding numbers to the names. In inventory you
85can have stuff with the same name to. The same named objects don't have
86to be the same object, they can be completely different. A simple
87object name to file name matching, with directories for contents, just
88wont work. Need to munge the names anyway.
89
90All name munging should produce names that are compatible with various
91OS file systems, compatible with URLs, add "_123" numbers at the end for
92duplicate names in the same directory, and auto add a file extension if
93one is missing. Probably should check the file type if there IS a file
94extension.
95
96Links and URLs.
97---------------
98
99Any asset file could be a stuffs.lnk file, which holds a relative path
100name or full URL pointing to the real asset. An external lspace server
101would return the .omg file when the stuffs URL is requested, or an
102actual asset file when those are requested.
103
104Would have to do copy on write for editing and other state changes, not
105including script state changes.
106
107Probably need to store other info in the .lnk file if it's a URL, SHA-1
108of the original file, other web cache info. Which starts to encroach on
109web proxy / cache territory, which we may not want to do, since we want
110to use real ones instead of crappy LL cache.
111
112Actually, file names / URLs in .omg files would mostly be relative to
113the file name / URL of the sim, and all the way down, so relative to the
114directory things are in. It's up to the client to keep track of where
115they are and build appropriate full URL / full path file names.
116
117UUIDS.
118------
119
120Original LL UUIDs are the usual 36 byte string representing 32 lower
121case hex characters and some dashes, encoding a 128 bit number. I was
122inspired by git using SHA-1 hashes for content addressable assets.
123SHA-1 hashes are 40 character hex codes representing 160 bit numbers
124that are calculated based on the content. So the same content will give
125the same SHA-1 hash. Git has proved that you only need the first digits
126of the SHA-1 hash to ensure uniqueness, so it's feasable to use only the
127first 128 bits of SHA-1 hashes to squeeze it into a UUID for the
128purposes of uniquely identifying assets. Precisely what git does. This
129means it could be backwards compatible with LL's use of UUIDs.
130
131Since the SHA-1 code of identical files is the same, we could use this
132to reduce duplicated large assets that never change, like textures and
133sounds. This will be a big win.
134
135I think we can get away with not storing SHA-1 hashes permanently, just
136use them for in memory references, but cache them to disk separately.
137The caches can be recreated at any time, since the SHA-1 hashes can be
138calculated based on the data in the assets. So no UUIDs stored in .omg
139files, just relative file / URL friendly names. The UUID / SHA-1 hashes
140are mostly for keeping in memory as keys to stuff, coz they can shrink
141down to a long long 128 bit integer.
142
143Each asset file, whether texture, script, mesh, text file, etc, comes
144with a matching .sha1 file that holds the SHA-1 hash of that file. .lnk
145files get hashed to, so that each copy of a linked stuffs gets it's own
146SHA-1 hash, but in this case the "content" is the relative path name.
147The .sha1 files of the real asset .lnk files point to can be found in
148the same place the real asset file is.
149
150There will be a .sha1 directory full of files with the SHA-1 hashes as
151part of the name, and the rest being similar to a .lnk file, a path to
152the asset or .lnk file. Would save love server needing to keep that all
153in memory all the time.
154
155If the file system date stamp for the asset file is later than the one
156for the .sha1 file, then someone edited the file, recreate the .sha1
157files.
158
159All the SHA-1 hashes can be recreated at any time, using file system
160date stamps to tell if one is stale. They are only used internally to a
161running system, to pass small identifiers around, and to fake LL UUIDs
162for LSL scripts. When a SHA-1 hash is calculated for a new asset, it
163gets stored in the .sha1, but if it already exists in .sha1, then the
164asset is replaced by that sha1.lnk file, thus automatically
165deduplicating assets.
166
167On 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
200People could even be free to use their own organising directory
201structure. A directory for ground level, and one for each sky box for
202instance. Relative paths inside .omg files sorts that all out.
203
204A sims index.omg file might be constantly updated for busy sims. Could
205generate it on the fly by the lspace server, based on the actual
206contents of the sim directory. Alternative lspace servers could just
207use a CMS system for all of this anyway. They would still use the same
208structure for URLs and .omg files.
209
210Avatars.
211--------
212
213Storing avatars in this way isn't such a good idea? Avatars could have
214their own avatar.omg dealing with shape, skin, clothes, attachments,
215etc. But instead of a client asking for a list, avatar arrivals and
216departures are driven by love. Though try to keep avatars as "just
217ordinary object, but with a person controlling it". Still, they move
218around a lot.
219
220Avatar.omg would live on the users hard drive, but sent to the love
221server on login, and after any change.
222
223Misc.
224-----
225
226Right now I'm using Lua style .omg files, but eet would be a better
227choice I think. Saves having to write a Lua table to C structure
228system, which eet already has, sorta. Lua tables are at least more
229readable while I consider the design, but likely use eet instead when I
230have to write code to read the suckers. .omg files are managed by the
231love server, so fiddling with them is an expert thing anyway.
232
233Should have a tool to validate a sims files and recreate te caches.
234
235Remaining issues.
236-----------------
237
238Owner / group UUID might be better dealt with elsewhere? Coz links.
239Also, we wont replicate the LL user / group stuff exactly, but morph
240into more standardised variations. Jabber users, jabber group rosters,
241OS users, web site users, etc. So just provide an abstraction, and an
242example or two.
243
244The 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
193A major goal is to have the disk structure of a sim (and inventory) be
194decently human readable. The assets should be stored as normal files of
195the appropriate type, so that they can be edited with normal editing
196software like blender, gimp, a text editor, etc.
197
198A major LL created problem is that in world objects can have the same
199name, though stuff in an objects inventory is forced to have unique
200names by automatically adding numbers to the names. In inventory you
201can have stuff with the same name to. The same named objects don't have
202to be the same object, they can be completely different. A simple
203object name to file name matching, with directories for contents, just
204wont work. Perhaps the automatic adding of numbers thing would be best?
205All names have to be coerced into operating system friendly names
206anyway, so there still needs to be some sort of mapping between objects
207and their names. Not to mention URL escaping for names to. Try to
208combine both.
209
210Should have a tool to validate a sims files.
211
212Sooo, 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
244Yes, 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
251People could even be free to use their own organising directory
252structure. A directory for ground level, and one for each sky box for
253instance. Relative paths inside .omg files sorts that all out.
254
255Actually, file names / URLs in .omg files would mostly be relative to
256the file name / URL of the sim, and all the way down, so relative to the
257directory things are in. It's up to the client to keep track of where
258they are and build appropriate full URL / full path file names.
259
260A 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
265Storing 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
271Right now I'm using Lua style .omg files, but eet would be a better
272choice I think. Saves having to write a Lua table to C structure
273system, which eet already has, sorta. Lua tables are at least more
274readable while I consider the design, but likely use eet instead when I
275have to write code to read the suckers.
276
277Might be useful to have a UUID -> asset file .cache directory, or
278something similar? Could save love server needing to keep that all in
279memory all the time. Plus, an issue with using sha-1 UUIDs and keeping
280them inside the .omg files is that this changes the sha-1 hash. Should
281think about keeping uuid's outside of them. Perhaps a .sha1 file along
282side each .omg file and asset file? Don't bother with links, if an
283asset is a link, just look for the .sha1 file where the real file is.
284The UUIDs are mostly for keeping in memory as keys to stuff, coz they
285can shrink down to a long. On the other hand, duplicated objects still
286need their own UUIDs to refer to each copy / link. Sha-1 the relative
287path to the link? It all gets trickier when assets are on different
288lspace servers, not to mention some OSes don't support links very well,
289or at all.
290
291objectName.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.
292objectName.lnk + objectName.sha1 .lnk is a relative file name to objectName.omg
293objectName.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
301If 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