bacommon.workspace package¶
Functionality related to ballistica.net workspaces.
Submodules¶
bacommon.workspace.assetsv1 module¶
Public types for assets-v1 workspaces.
While this module is currently only used server-side, its source code can be useful as reference when setting workspace config data by hand or for use in client-side workspace modification tools. There may be advanced settings that are not accessible through the UI/etc.
- class bacommon.workspace.assetsv1.AssetsV1GlobalVals(base_assets: str | None = None, base_assets_filter: str = '', docs: str = '')[source]¶
Bases:
objectGlobal values for an assets_v1 workspace.
- class bacommon.workspace.assetsv1.AssetsV1PathVals[source]¶
Bases:
IOMultiType[AssetsV1PathValsTypeID]Top level class for path vals classes.
- classmethod get_type(type_id: AssetsV1PathValsTypeID) type[AssetsV1PathVals][source]¶
Return a specific subclass given a type-id.
Should be overridden by child classes. Generally, users of the class should call
get_type_cached()instead of this, as it is more efficient.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- classmethod get_type_id_storage_name() str[source]¶
Return the key used to store type id in serialized data.
The default is a short obscure value so that it is unlikely to conflict with members of individual type attrs, but in some cases one might prefer to serialize it to something simpler like ‘type’ by overriding this call. One just needs to make sure that no encompassed types serialize anything to that same name themself (dataclassio will error if they do).
- class bacommon.workspace.assetsv1.AssetsV1PathValsAudioV1(audio_role: AudioRole = AudioRole.DEFAULT, audio_quality: AudioQuality = AudioQuality.DEFAULT, docs: str = '')[source]¶
Bases:
AssetsV1PathValsPath-specific values for an audio source in an assets_v1 workspace.
The per-sound authoring knobs (
AudioRole,AudioQuality) are module-level types in this module.- audio_quality: AudioQuality = 'default'¶
- docs: str = ''¶
Optional free-form documentation for this asset, surfaced as a comment above the asset in generated wrapper modules (and in the Sphinx docs). Empty string means no docs.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.workspace.assetsv1.AssetsV1PathValsCubeMapV1(docs: str = '')[source]¶
Bases:
AssetsV1PathValsPath-specific values for a cube map (
.cubemapdir) in a workspace.Cube maps are reflection textures with no Python API (decision #24), so they aren’t wrapper-visible. This currently carries only optional
docs– stored for completeness/consistency with other asset kinds, but not yet consumed by anything (it’ll have a home if/when cube maps gain a Python surface). Keyed inworkspace.json’spathdict by the.cubemapdirectory path.- docs: str = ''¶
Optional free-form documentation for this cube map. Stored but not yet surfaced anywhere (cube maps have no wrapper entry). Empty string means no docs.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.workspace.assetsv1.AssetsV1PathValsGroupV1(docs: str = '')[source]¶
Bases:
AssetsV1PathValsPath-specific values for a group (directory) in a workspace.
A group builds no asset of its own; this exists purely to carry optional
docs(decision #28) that become the generated wrapper group class’s docstring. Keyed inworkspace.json’spathdict by the directory path (e.g.texturesormydir/subdir).- docs: str = ''¶
Optional free-form documentation for this group, used as the generated wrapper group class’s docstring (a trailing “See source for the full asset list.” is always appended). Empty string means fall back to the auto-generated docstring.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.workspace.assetsv1.AssetsV1PathValsMeshV1(mesh_role: MeshRole = MeshRole.DEFAULT, docs: str = '')[source]¶
Bases:
AssetsV1PathValsPath-specific values for a mesh source in an assets_v1 workspace.
The per-mesh authoring knob (
MeshRole) is a module-level type in this module.- docs: str = ''¶
Optional free-form documentation for this asset, surfaced as a comment above the asset in generated wrapper modules (and in the Sphinx docs). Empty string means no docs.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.workspace.assetsv1.AssetsV1PathValsStrV1(up_to_date_state: str | None = None)[source]¶
Bases:
AssetsV1PathValsPath-specific values for an assets_v1 workspace path.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- class bacommon.workspace.assetsv1.AssetsV1PathValsTexV1(texture_quality: TextureQuality = TextureQuality.DEFAULT, texture_role: Role = Role.DEFAULT, astc_settings: AstcSettings = <factory>, bc7_settings: Bc7Settings = <factory>, docs: str = '')[source]¶
Bases:
AssetsV1PathValsPath-specific values for an assets_v1 workspace path.
The per-texture quality knobs (
TextureQuality,Role,AstcSettings,Bc7Settings) are module-level types in this module.- astc_settings: AstcSettings¶
Per-format encode settings, consulted only when
texture_qualityisCUSTOM. Fully defaulted so a texture never has to store them explicitly.
- bc7_settings: Bc7Settings¶
- docs: str = ''¶
Optional free-form documentation for this asset, surfaced as a comment above the asset in generated wrapper modules (and in the Sphinx docs). Empty string means no docs.
- classmethod get_type_id() AssetsV1PathValsTypeID[source]¶
Return the type-id for this subclass.
- normalize() None[source]¶
Reset redundant/unused settings to defaults, in place.
A pure tidiness pass to run before storing: it never changes the resolved result, only drops dead data so
store_default=Falsecan strip it from workspace.json. Resolution consults the per-format settings only when the top-leveltexture_qualityisCUSTOM, and a format’s explicitblock_size/rdoonly when that format’s owntexture_qualityisCUSTOM– so anything outside those paths is unused and gets cleared here.
- texture_quality: TextureQuality = 'default'¶
- class bacommon.workspace.assetsv1.AssetsV1PathValsTypeID(*values)[source]¶
Bases:
EnumTypes of vals we can store for paths.
- AUDIO_V1 = 'audio_v1'¶
- CUBE_MAP_V1 = 'cube_map_v1'¶
- GROUP_V1 = 'group_v1'¶
- MESH_V1 = 'mesh_v1'¶
- STR_V1 = 'str_v1'¶
- TEX_V1 = 'tex_v1'¶
- class bacommon.workspace.assetsv1.AssetsV1StringFile[source]¶
Bases:
IOMultiType[AssetsV1StringFileTypeID]Top level class for our multitype.
- classmethod get_type(type_id: AssetsV1StringFileTypeID) type[AssetsV1StringFile][source]¶
Return the subclass for each of our type-ids.
- classmethod get_type_id() AssetsV1StringFileTypeID[source]¶
Return the type-id for this subclass.
- classmethod get_type_id_storage_name() str[source]¶
Return the key used to store type id in serialized data.
The default is a short obscure value so that it is unlikely to conflict with members of individual type attrs, but in some cases one might prefer to serialize it to something simpler like ‘type’ by overriding this call. One just needs to make sure that no encompassed types serialize anything to that same name themself (dataclassio will error if they do).
- class bacommon.workspace.assetsv1.AssetsV1StringFileTypeID(*values)[source]¶
Bases:
EnumType ID for each of our subclasses.
- V1 = 'v1'¶
- class bacommon.workspace.assetsv1.AssetsV1StringFileV1(input: str, input_modtime: datetime.datetime, style_preset: StylePreset = StylePreset.NONE, outputs: dict[Locale, Output]=<factory>)[source]¶
Bases:
AssetsV1StringFileOur initial version of string file data.
- class Output(modtime: datetime, value: str = '', selector: StringSelector | None = None)[source]¶
Bases:
objectRepresents a single localized output.
- selector: StringSelector | None = None¶
Optional render-time selector (plural/select); set instead of
valuefor an entry whose value is chosen at render time.
- class StylePreset(*values)[source]¶
Bases:
EnumPreset for general styling in translated strings.
- LOUD = 'loud'¶
- NONE = 'none'¶
- SOFT = 'soft'¶
- TITLE = 'title'¶
- classmethod get_type_id() AssetsV1StringFileTypeID[source]¶
Return the type-id for this subclass.
- input_modtime: datetime.datetime¶
- style_preset: StylePreset = 'none'¶
- class bacommon.workspace.assetsv1.AstcBlockSize(*values)[source]¶
Bases:
EnumASTC square block size — the mobile bitrate lever.
Smaller block = more bits per texel = higher quality + larger output. Consulted only when an
AstcSettingshas itstexture_qualityset toCUSTOM; otherwise the blanketLOW/DEFAULT/HIGHmap to a value in this range (LOW=TWELVE_BY_TWELVE,HIGH=FOUR_BY_FOUR).- EIGHT_BY_EIGHT = '8x8'¶
- FIVE_BY_FIVE = '5x5'¶
- FOUR_BY_FOUR = '4x4'¶
- SIX_BY_SIX = '6x6'¶
- TEN_BY_TEN = '10x10'¶
- TWELVE_BY_TWELVE = '12x12'¶
- class bacommon.workspace.assetsv1.AstcSettings(texture_quality: TextureQuality = TextureQuality.DEFAULT, block_size: AstcBlockSize = AstcBlockSize.SIX_BY_SIX)[source]¶
Bases:
objectPer-texture ASTC (mobile) encode settings.
Consulted only when the texture’s top-level
texture_qualityisCUSTOM. Its owntexture_qualitymay in turn beCUSTOMto use the explicitblock_size; otherwiseLOW/DEFAULT/HIGHmap to the encoder’s block-size range. Fully defaulted so a texture never has to store it explicitly.- block_size: AstcBlockSize = '6x6'¶
- texture_quality: TextureQuality = 'default'¶
- class bacommon.workspace.assetsv1.AudioQuality(*values)[source]¶
Bases:
EnumPer-sound authoring quality knob (asset-packages decision #25).
Mirrors the texture knob’s LOW/DEFAULT/HIGH pattern. Defined from day one as the escape hatch for content whose default encode budget doesn’t fit (e.g. a short pre-mixed UI sound sharing music’s bitrate), but nothing consumes it yet — the recipe carries it in its cache key only, so wiring it up later rebuilds correctly.
- DEFAULT = 'default'¶
- HIGH = 'high'¶
- LOW = 'low'¶
- class bacommon.workspace.assetsv1.AudioRole(*values)[source]¶
Bases:
EnumA sound’s channel/encode contract (asset-packages decision #25).
Names the technical contract, not a content category — “music” deliberately does not exist as a build-time concept (volume routing stays a runtime play-flag; streaming is a length-derived engine policy).
DEFAULT— spatialization-ready: downmixed to mono at encode (OpenAL only spatializes mono; a hard requirement, not a size optimization). The vast majority of sounds.PRE_MIXED— an authored mix: channels preserved (≤2) and the sound always plays listener-space. The recipe stamps aBA_ROLE=pre_mixedvorbis comment tag so the engine knows at load time (channel count alone can’t carry the bit — a mono pre-mixed source stays mono). Music, plus any intentionally stereo (or otherwise authored-mix) sound.
- DEFAULT = 'default'¶
- PRE_MIXED = 'pre_mixed'¶
- class bacommon.workspace.assetsv1.Bc7Rdo(*values)[source]¶
Bases:
EnumBC7 RDO (rate-distortion optimization) lambda — the desktop lever.
BC7 is a fixed 8bpp block format, so its size lever is RDO: higher lambda steers the encoder toward more zlib/LZ-compressible output (smaller on-disk) at the cost of quality.
OFFdisables RDO (best quality, largest). Consulted only when aBc7Settingshas itstexture_qualityset toCUSTOM; otherwise the blanketLOW/DEFAULT/HIGHmap to a value in this range (LOW=FOUR,HIGH=OFF).- FOUR = '4'¶
- OFF = 'off'¶
- ONE = '1'¶
- TWO = '2'¶
- ZERO_POINT_FIVE = '0.5'¶
- ZERO_POINT_ONE_TWO_FIVE = '0.125'¶
- ZERO_POINT_TWO_FIVE = '0.25'¶
- class bacommon.workspace.assetsv1.Bc7Settings(texture_quality: TextureQuality = TextureQuality.DEFAULT, rdo: Bc7Rdo = Bc7Rdo.ONE)[source]¶
Bases:
objectPer-texture BC7 (desktop) encode settings.
Consulted only when the texture’s top-level
texture_qualityisCUSTOM. Its owntexture_qualitymay in turn beCUSTOMto use the explicitrdolambda; otherwiseLOW/DEFAULT/HIGHmap to the encoder’s RDO range. Fully defaulted so a texture never has to store it explicitly.- texture_quality: TextureQuality = 'default'¶
- class bacommon.workspace.assetsv1.MeshRole(*values)[source]¶
Bases:
EnumWhat a mesh
.objsource builds (asset-packages decision #26).DEFAULT— a display mesh: compiled to the engine’s binary.bobformat (welded/quantized verts, vertex-cache-optimized index order) and served from the flavor-varyingmeshesbucket (headless builds get none).COLLISION— a collision mesh: compiled to the engine’s binary.cobformat (positions + indices for the physics trimesh) and served from the flavor-invariantconstantbucket — every build including headless gets it, and the bytes are identical across all flavors (networked sims/replays must agree on collision geometry).
- COLLISION = 'collision'¶
- DEFAULT = 'default'¶
- class bacommon.workspace.assetsv1.Role(*values)[source]¶
Bases:
EnumWhat a texture is for (its authoring intent).
Drives mip-filtering math and encoder flags (asset-packages initiative decisions #19/#23). Intent-based rather than a bundle of low-level mechanical flags — the recipe maps each role to a concrete filtering/encoding behavior.
normal_map/dataare reserved slots for when such content (and the compressed- profile recipes) land.- DEFAULT = 'default'¶
sRGB color with straight opacity alpha. The pipeline premultiplies it by its alpha for storage (decision #23): premult-weighted, halo-free mip filtering in the requested render_space, premult output bytes,
ALPHA_PREMULTIPLIEDDFD flag set. The common case for color sprites. Renders correctly only with premult-blend (the renderer wiring lands in a later step; until thenDEFAULToutput shows darkened edges under the legacy straight-blend path).
- SOURCE_PREMULTIPLIED = 'source_premultiplied'¶
sRGB color whose SOURCE RGB is already premultiplied by its alpha (e.g. glow sprites — they carry additive
RGB > alphavalues that straight alpha cannot represent). The pipeline does NOT re-multiply; mips filter the premultiplied RGB directly (in the requested render_space) and the flag is set. Renders identically toDEFAULT(both premult-blend); they differ only in whether the pipeline applies the multiply.
- STRAIGHT_ALPHA = 'straight_alpha'¶
sRGB color with straight alpha whose RGB channels carry meaningful color even in transparent regions, so they must be preserved (decision #23). The pipeline does NOT premultiply: mips filter RGB and alpha INDEPENDENTLY (color still filtered in the requested render_space, but with no premult round-trip, which would zero — and fail to recover — the transparent-region color). Straight output bytes;
ALPHA_PREMULTIPLIEDflag clear. Renders with ordinary straight-alpha blending.
- class bacommon.workspace.assetsv1.TextureQuality(*values)[source]¶
Bases:
EnumPer-texture authoring quality knob (decision #19).
DEFAULTis the normal case (the vast majority of textures);LOWandHIGHare deliberate per-texture overrides for special cases (e.g.HIGHfor a hero texture that must stay crisp,LOWfor one that can afford to be cheap). NamedDEFAULTrather thanMEDIUMto communicate that — it’s the baseline, not a middle setting you’d routinely reach past.LOW/DEFAULT/HIGHare blanket settings that map to a sensible value for whichever encoder a profile uses (ASTC block size on mobile, BC7 RDO lambda on desktop).CUSTOMinstead defers to the per-formatAstcSettings/Bc7Settingsso a texture can be tuned independently per encoder (e.g. ASTCHIGHwhile BC7DEFAULT). Distinct from the bucket-levelTextureTier.- CUSTOM = 'custom'¶
- DEFAULT = 'default'¶
- HIGH = 'high'¶
- LOW = 'low'¶
- class bacommon.workspace.assetsv1.WrapperType(*values)[source]¶
Bases:
EnumPython wrapper-module flavor for an asset-package version.
Selects which feature-set’s loader API the generated wrapper delegates to. Members today correspond 1:1 with feature-sets, but the type is deliberately named
WrapperType(notWrapperFeatureset) to leave room for non-featureset-shaped variants (e.g. tooling-only or future loader APIs) without a rename.- BABASE = 'babase'¶
Strings-only wrapper (asset-packages strings phase). Strings resolve via
_babase.get_resource(a base-level concept, not a scene/UI loader), so they live in their own babase-rooted wrapper whose leaves are call-time-resolvedstraccessors.
- BASCENEV1 = 'bascenev1'¶
- BAUIV1 = 'bauiv1'¶
- bacommon.workspace.assetsv1.complete_locale_values(string_files: dict[str, AssetsV1StringFileV1], locale: Locale) dict[str, str | StringSelector][source]¶
English-completed per-locale values for a set of string files.
Maps each string’s logical name to its value for
locale: the locale’s own output, else the English output, else the raw English briefinput. So every locale’s map carries the complete key set with graceful English fallback – untranslated strings still render (in English) rather than failing, and every locale’s key set is identical.The shared value-selection both the asset-build string recipe and the langstr vendor command route through (paired with
serialize_language_blob()) so the built and vendored blobs can’t drift.