Instead of caching PNGImage results, cache mjCTexture and mjCHField assets.

PiperOrigin-RevId: 813307632
Change-Id: I9de8b46423f57240d22811571d0533b010ee1e2b
This commit is contained in:
Sam Haves
2025-09-30 09:43:42 -07:00
committed by Copybara-Service
parent 59d0676dcc
commit 4d590afdad
2 changed files with 97 additions and 40 deletions
+9 -5
View File
@@ -1395,6 +1395,7 @@ class mjCHField : public mjCHField_, private mjsHField {
private:
void Compile(const mjVFS* vfs); // compiler
std::string GetCacheId(const mjResource* resource, const std::string& asset_type);
void LoadCustom(mjResource* resource); // load from custom format
void LoadPNG(mjResource* resource); // load from PNG format
};
@@ -1444,11 +1445,14 @@ class mjCTexture : public mjCTexture_, private mjsTexture {
private:
void Compile(const mjVFS* vfs); // compiler
void Builtin2D(void); // make builtin 2D
void BuiltinCube(void); // make builtin cube
void Load2D(std::string filename, const mjVFS* vfs); // load 2D from file
void LoadCubeSingle(std::string filename, const mjVFS* vfs); // load cube from single file
void LoadCubeSeparate(const mjVFS* vfs); // load cube from separate files
// store texture into asset cache
std::string GetCacheId(const mjResource* resource, const std::string& asset_type);
void Builtin2D(void); // make builtin 2D
void BuiltinCube(void); // make builtin cube
void Load2D(std::string filename, const mjVFS* vfs); // load 2D from file
void LoadCubeSingle(std::string filename,
const mjVFS* vfs); // load cube from single file
void LoadCubeSeparate(const mjVFS* vfs); // load cube from separate files
void FlipIfNeeded(std::vector<std::byte>& image, unsigned int w, unsigned int h);