Remove custom mujoco.texture format.
PiperOrigin-RevId: 960257562 Change-Id: I318c84d82576d405f0a5d8510acd5bab5f08c9af
This commit is contained in:
committed by
Copybara-Service
parent
84950fa371
commit
6fe04aa8d3
@@ -5293,43 +5293,6 @@ void mjCTexture::LoadKTX(mjResource* resource, std::vector<std::byte>& image,
|
||||
}
|
||||
|
||||
// load custom file
|
||||
void mjCTexture::LoadCustom(mjResource* resource, std::vector<std::byte>& image,
|
||||
unsigned int& w, unsigned int& h, bool& is_srgb) {
|
||||
const void* buffer = 0;
|
||||
int buffer_sz = mju_readResource(resource, &buffer);
|
||||
|
||||
// still not found
|
||||
if (buffer_sz < 0) {
|
||||
throw mjCError(this, "could not read texture file '%s'", resource->name);
|
||||
} else if (!buffer_sz) {
|
||||
throw mjCError(this, "texture file is empty: '%s'", resource->name);
|
||||
}
|
||||
|
||||
|
||||
// read dimensions
|
||||
int* pint = (int*)buffer;
|
||||
w = pint[0];
|
||||
h = pint[1];
|
||||
|
||||
// assume linear color space
|
||||
is_srgb = false;
|
||||
|
||||
// check dimensions
|
||||
if (w < 1 || h < 1) {
|
||||
throw mjCError(this, "Non-PNG texture, assuming custom binary file format,\n"
|
||||
"non-positive texture dimensions in file '%s'", resource->name);
|
||||
}
|
||||
|
||||
// check buffer size
|
||||
if (buffer_sz != 2*sizeof(int) + w*h*3*sizeof(char)) {
|
||||
throw mjCError(this, "Non-PNG texture, assuming custom binary file format,\n"
|
||||
"unexpected file size in file '%s'", resource->name);
|
||||
}
|
||||
|
||||
// allocate and copy
|
||||
image.resize(w*h*3);
|
||||
memcpy(image.data(), (void*)(pint+2), w*h*3*sizeof(char));
|
||||
}
|
||||
|
||||
void mjCTexture::FlipIfNeeded(std::vector<std::byte>& image, unsigned int w,
|
||||
unsigned int h) {
|
||||
@@ -5398,12 +5361,7 @@ void mjCTexture::LoadFlip(std::string filename, const mjVFS* vfs,
|
||||
|
||||
std::string asset_type = GetAssetContentType(filename, content_type_);
|
||||
|
||||
// fallback to custom
|
||||
if (asset_type.empty()) {
|
||||
asset_type = "image/vnd.mujoco.texture";
|
||||
}
|
||||
|
||||
if (asset_type != "image/png" && asset_type != "image/ktx" && asset_type != "image/vnd.mujoco.texture") {
|
||||
if (asset_type != "image/png" && asset_type != "image/ktx") {
|
||||
throw mjCError(this, "unsupported content type: '%s'", asset_type.c_str());
|
||||
}
|
||||
|
||||
@@ -5423,8 +5381,6 @@ void mjCTexture::LoadFlip(std::string filename, const mjVFS* vfs,
|
||||
throw mjCError(this, "cannot flip KTX textures");
|
||||
}
|
||||
LoadKTX(resource, image, w, h, is_srgb);
|
||||
} else {
|
||||
LoadCustom(resource, image, w, h, is_srgb);
|
||||
}
|
||||
} catch(mjCError err) {
|
||||
mju_closeResource(resource);
|
||||
|
||||
@@ -1494,8 +1494,6 @@ class mjCTexture : public mjCTexture_, private mjsTexture {
|
||||
unsigned int& w, unsigned int& h, bool& is_srgb);
|
||||
void LoadKTX(mjResource* resource, std::vector<std::byte>& image,
|
||||
unsigned int& w, unsigned int& h, bool& is_srgb);
|
||||
void LoadCustom(mjResource* resource, std::vector<std::byte>& image,
|
||||
unsigned int& w, unsigned int& h, bool& is_srgb);
|
||||
|
||||
bool clear_data_; // if true, data_ is empty and should be filled by Compile
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user