build: regenerate bundles (model/sourcemdl, codecs/model/SourceAnim)

This commit is contained in:
4DBug committed 2026-11-01 19:21:22 -06:00
1 parent 80fd9cf1e8
commit 7a69ba8455
4 files changed
+508 -170

No files matched your search

+174 -6
View File
@@ -2519,7 +2519,7 @@ local list= {
path = "model/sourcemdl",
extensions = { "mdl" },
mime = { "model/x-source-mdl" },
deps = { "core/Err", "core/Bytes", "core/Input", "Types", "codecs/image/Half", "codecs/model/Mat4", "codecs/model/Rig", "codecs/model/SourceAnim" },
deps = { "core/Err", "core/Bytes", "core/Input", "Types", "codecs/image/Half", "codecs/model/Mat4", "codecs/model/Rig", "codecs/model/SourceAnim", "codecs/text/KeyValues" },
caps = { decode = true, encode = false, skins = true, morph = true, animation = true, lods = true },
load = function()
return __include("model/sourcemdl")
@@ -169015,10 +169015,8 @@ return Write
end
__FILES["model/sourcemdl"] = function()
local __compat = __compat local buffer, bit32, type, __iter = __compat.buffer, __compat.bit32, __compat.type, __compat.__iter --!strict
-- model/sourcemdl: Source engine studio models ("IDST" v44-49) with their .vvd vertices (LOD fixups), .vtx strips
-- (.dx90 / .dx80 / .sw), optional .phy collision and .ani animation blocks, all through opts.resolve / opts.files.
-- Skeleton, procedural bones, skin families, body parts, LODs, flexes, attachments, hitboxes, sequences and
-- animations; layouts from Source SDK 2013 studio.h / optimize.h, cross-checked with srctools and SourceIO (both MIT).
-- model/sourcemdl: Source engine studio models ("IDST" v44-49) with .vvd / .vtx (.dx90 / .dx80 / .sw) and optional .phy /
-- .ani / .vmt through opts.resolve / opts.files; Source SDK 2013 studio.h / optimize.h layouts, checked with srctools.
-- Not supported: v52+ frame animations, IK rules, movement, eyeball shading, $includemodel animations.
-- ------------------------------------------------------------------------------------------------ requires
@@ -169031,6 +169029,7 @@ local Vvd = __include("model/sourcemdl/Vvd")
local Vtx = __include("model/sourcemdl/Vtx")
local Phy = __include("model/sourcemdl/Phy")
local Build = __include("model/sourcemdl/Build")
local Material = __include("model/sourcemdl/Material")
-- ------------------------------------------------------------------------------------------------ contract
local SourceMdl = {
@@ -169038,7 +169037,7 @@ local SourceMdl = {
category = "model",
extensions = { "mdl" },
mime = { "model/x-source-mdl" },
deps = { "core/Err", "core/Bytes", "core/Input", "Types", "codecs/image/Half", "codecs/model/Mat4", "codecs/model/Rig", "codecs/model/SourceAnim" },
deps = { "core/Err", "core/Bytes", "core/Input", "Types", "codecs/image/Half", "codecs/model/Mat4", "codecs/model/Rig", "codecs/model/SourceAnim", "codecs/text/KeyValues" },
caps = { decode = true, encode = false, skins = true, morph = true, animation = true, lods = true },
}
-- ------------------------------------------------------------------------------------------------ types
@@ -169060,6 +169059,7 @@ local SourceMdl = {
local VTX = { "dx90.vtx", "dx80.vtx", "sw.vtx", "vtx" }
-- ------------------------------------------------------------------------------------------------ sniff
@@ -169174,6 +169174,9 @@ local size = r.limit - r.base
if not scene then
return nil, Err.from(berr)
end
if not (opts and opts.materials == false) then
Material.apply(scene, h.textures, h.cdmaterials, opts, warnings)
end
local src = scene.meta.source
src.vtx = vtxName
return scene, nil
@@ -169611,6 +169614,171 @@ end
return Build
end
__FILES["model/sourcemdl/Material"] = function()
local __compat = __compat local type, __iter = __compat.type, __compat.__iter --!strict
-- model/sourcemdl/Material: the MDL's texture names through $cdmaterials to materials/<dir><name>.vmt (the engine's
-- search order, then the bare name), parsed with codecs/text/KeyValues; "patch" materials (include + insert /
-- replace) applied. $basetexture / $bumpmap ($normalmap) become .vtf texture references for F.model.loadTextures;
-- $translucent / $alphatest / $nocull / $color map to the PBR fields, every parameter is kept in extras.vmt.
local Types = __include("Types")
local Input = __include("core/Input")
local KeyValues = __include("codecs/text/KeyValues")
local Material = {}
local function dir(s)
local d = string.gsub(s, "\\", "/")
d = string.gsub(d, "^/+", "")
if d ~= "" and string.sub(d, -1) ~= "/" then
d =d.. "/"
end
return d
end
local function path(s)
local p = string.gsub(string.gsub(s, "\\", "/"), "^/+", "")
return (string.gsub(p, "%.[vV][mMtT][tTfF]$", ""))
end
local function load(opts, uri)
local b = Input.sibling(opts, uri) or Input.sibling(opts, string.lower(uri))
if not b then
return uri, nil
end
local kv = KeyValues.parse(b, { escapes = false, resolve = function(name)
return Input.sibling(opts, name)
end })
return uri, kv
end
-- { shader, params (lower-case keys) } of a parsed .vmt, patch includes applied (depth 8)
local function flatten(opts, kv, depth)
local first = kv[1]
if not first or type(first.value) ~= "table" then
return nil, {}
end
local shader, body = first.key, first.value
local params= {}
if string.lower(shader) == "patch" and depth < 8 then
local inc = KeyValues.get(body, "include")
local base= nil
if type(inc) == "string" then
local _, b = load(opts, path(inc) .. ".vmt")
base = b
end
if base then
shader, params = flatten(opts, base, depth + 1)
end
for _, p in __iter(body) do
local k = string.lower(p.key)
if (k == "insert" or k == "replace") and type(p.value) == "table" then
for _, q in __iter(p.value) do
local qk = string.lower(q.key)
if k == "insert" or params[qk] ~= nil then
params[qk] = (q.value == "" and{nil }or{q.value
})[1] end
end
end
end
return shader, params
end
for _, p in __iter(body) do
params[string.lower(p.key)] = p.value
end
return shader, params
end
local function num(v)
return (type(v) == "number" and{v }or{(type(v) == "string" and{(tonumber(v) )}or{nil
})[1]})[1]end
local function color(v)
if type(v) ~= "string" then
return nil
end
local r, g, b = string.match(v, "^%s*[%[{]%s*([%d.eE+-]+)%s+([%d.eE+-]+)%s+([%d.eE+-]+)")
if not r then
return nil
end
local scale = string.match(v, "^%s*{") and 1 / 255 or 1
return { ((tonumber(r) )) * scale, ((tonumber(g) )) * scale, ((tonumber(b) )) * scale }
end
function Material.apply(scene, textures, cdmaterials, opts, warnings)
if type(opts) ~= "table" or (opts.files == nil and opts.resolve == nil) then
return
end
local dirs= {}
for _, d in __iter(cdmaterials) do
local nd = dir(d)
if not table.find(dirs, nd) then
table.insert(dirs, nd)
end
end
if not table.find(dirs, "") then
table.insert(dirs, "")
end
local texIndex= {}
local function texture(v)
if type(v) ~= "string" or v == "" then
return nil
end
local uri = "materials/" .. path(v) .. ".vtf"
local i = texIndex[string.lower(uri)]
if not i then
table.insert(scene.textures, { name = path(v), uri = uri, mime = "image/x-vtf" })
i = #scene.textures
texIndex[string.lower(uri)] = i
end
return i
end
for i, t in __iter(textures) do
local __DARKLUA_CONTINUE_5=false repeat local mat = scene.materials[i]
local name = path(t.name)
local found, kv = nil, nil
for _, d in __iter(dirs) do
local uri, b = load(opts, "materials/" .. d .. name .. ".vmt")
if b then
found, kv = uri, b
break
end
end
if not kv then
table.insert(warnings, "material " .. t.name .. ": no .vmt")
__DARKLUA_CONTINUE_5=true break
end
local shader, p = flatten(opts, kv, 0)
local ex= mat.extras or {}
mat.extras = ex
ex.vmt = { path = found, shader = shader, params = p }
local base = texture(p["$basetexture"])
if base then
mat.baseColorTexture = { texture = base }
end
local bump = texture(p["$bumpmap"] or p["$normalmap"])
if bump then
mat.normalTexture = { texture = bump }
end
local c = color(p["$color2"]) or color(p["$color"])
if c then
mat.baseColor = { c[1], c[2], c[3], num(p["$alpha"]) or 1 }
elseif num(p["$alpha"]) then
mat.baseColor[4] = (num(p["$alpha"]) )
end
if num(p["$translucent"]) == 1 then
mat.alphaMode = "blend"
elseif num(p["$alphatest"]) == 1 then
mat.alphaMode = "mask"
mat.alphaCutoff = num(p["$alphatestreference"]) or 0.5
end
if num(p["$nocull"]) == 1 then
mat.doubleSided = true
end
__DARKLUA_CONTINUE_5=true until true if not __DARKLUA_CONTINUE_5 then break end end
end
return Material
end
__FILES["model/sourcemdl/Mdl"] = function()
local __compat = __compat local buffer, bit32, type, __iter = __compat.buffer, __compat.bit32, __compat.type, __compat.__iter --!strict
-- model/sourcemdl/Mdl: the studiohdr_t tables of Source MDL v44-49 (Source SDK 2013 public/studio.h layouts, SourceIO