model/blend: comments to specs only, a type fix; build: regenerate bundles
This commit is contained in:
1 parent
08f3b1c5bd
commit
be397639ea
9 files changed
+8471
-1102
No files matched your search
@@ -131,7 +131,6 @@ local function decompress(buf: buffer, o: number, n: number, opts: Options?): (b
|
||||
end
|
||||
|
||||
local function header(b: buffer, n: number): (number?, number, boolean, number, number, string?)
|
||||
-- -> header size, pointer size, little, version, format | nil, error
|
||||
if n < 12 or readstring(b, 0, 7) ~= "BLENDER" then
|
||||
return nil, 0, false, 0, 0, "not a .blend file (no BLENDER magic)"
|
||||
end
|
||||
@@ -425,7 +424,6 @@ function Blend.structOf(f: File, blk: Block): Struct?
|
||||
return f.dna.structs[blk.sdna + 1]
|
||||
end
|
||||
|
||||
-- element i (0-based) of a block, as its own SDNA struct or as `as` (a struct name)
|
||||
function Blend.struct(f: File, blk: Block, i: number?, as: string?): View?
|
||||
local s = if as then f.dna.byName[as] else f.dna.structs[blk.sdna + 1]
|
||||
if not s then
|
||||
@@ -535,8 +533,6 @@ local function scalar(f: File, t: string, size: number, o: number): number
|
||||
return readu8(b, o) -- char, uchar, uint8_t, bool
|
||||
end
|
||||
|
||||
-- a number (scalars), a string (char arrays), an array of numbers (other arrays), a View (embedded structs), the
|
||||
-- pointer key (pointers); nil when no field has any of the names
|
||||
function View.get(self: View, ...: string): any
|
||||
local fld = find(self, { ... })
|
||||
if not fld then
|
||||
@@ -619,7 +615,6 @@ function View.target(self: View, ...: string): Block?
|
||||
return Blend.resolve(self.file, self:ptr(...), self.block)
|
||||
end
|
||||
|
||||
-- the struct a pointer field points at (element i, 0-based), typed by the field's type or `as`
|
||||
function View.deref(self: View, name: string | { string }, i: number?, as: string?): View?
|
||||
local names: { any } = if type(name) == "table" then name else { name }
|
||||
local fld = find(self, names)
|
||||
@@ -639,7 +634,6 @@ function View.deref(self: View, name: string | { string }, i: number?, as: strin
|
||||
return Blend.struct(f, blk, i, sname)
|
||||
end
|
||||
|
||||
-- all elements of a pointer-to-array field: the block's count (or byte size / struct size when that is larger)
|
||||
function View.array(self: View, name: string | { string }, as: string?): { View }
|
||||
local first = self:deref(name, 0, as)
|
||||
if not first or not first.block then
|
||||
@@ -655,7 +649,6 @@ function View.array(self: View, name: string | { string }, as: string?): { View
|
||||
return out
|
||||
end
|
||||
|
||||
-- a pointer to an array of pointers (Material **mat, ActionLayer **layer_array, ...): n keys (default: the block size)
|
||||
function View.pointers(self: View, name: string | { string }, n: number?): { any }
|
||||
local names: { any } = if type(name) == "table" then name else { name }
|
||||
local fld = find(self, names)
|
||||
@@ -679,7 +672,6 @@ function View.pointers(self: View, name: string | { string }, n: number?): { any
|
||||
return out
|
||||
end
|
||||
|
||||
-- a ListBase field (first / last) walked through each element's `next`, typed as `as` or the first block's struct
|
||||
function View.list(self: View, name: string | { string }, as: string?, limit: number?): { View }
|
||||
local names: { any } = if type(name) == "table" then name else { name }
|
||||
local lb = self:sub(table.unpack(names))
|
||||
@@ -715,7 +707,6 @@ function View.list(self: View, name: string | { string }, as: string?, limit: nu
|
||||
return out
|
||||
end
|
||||
|
||||
-- the bytes a pointer field points at: (block offset, block size) in file.buf
|
||||
function View.data(self: View, ...: string): (number?, number)
|
||||
local blk = self:target(...)
|
||||
if not blk then
|
||||
@@ -724,7 +715,6 @@ function View.data(self: View, ...: string): (number?, number)
|
||||
return blk.offset, blk.size
|
||||
end
|
||||
|
||||
-- a NUL-terminated string behind a char pointer
|
||||
function View.cstring(self: View, ...: string): string?
|
||||
local blk = self:target(...)
|
||||
if not blk then
|
||||
@@ -735,7 +725,6 @@ function View.cstring(self: View, ...: string): string?
|
||||
return if z then string.sub(s, 1, z - 1) else s
|
||||
end
|
||||
|
||||
-- an ID's name without its two-letter code ("OBCube" -> "Cube")
|
||||
function View.idName(self: View): string?
|
||||
local id = self:sub("id")
|
||||
local n = if id then id:str("name") else self:str("name")
|
||||
|
||||
Reference in new issue
Block a user