Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rbsheth committed Jul 22, 2020
1 parent 28852fd commit b1980a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions code/AssetLib/M3D/m3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -5578,9 +5578,9 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
} else
out--;
break;
case m3dpf_uint8: *out++ = m->prop[i].value.num; break;
case m3dpf_uint8: *out++ = (uint8_t)m->prop[i].value.num; break;
case m3dpf_uint16:
*((uint16_t *)out) = m->prop[i].value.num;
*((uint16_t *)out) = (uint16_t)m->prop[i].value.num;
out += 2;
break;
case m3dpf_uint32:
Expand Down Expand Up @@ -5655,7 +5655,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
face[i].data.normal[1] == M3D_UNDEF || face[i].data.normal[2] == M3D_UNDEF) ?
0 :
2);
*out++ = k;
*out++ = (uint8_t)k;
for (j = 0; j < 3; j++) {
out = _m3d_addidx(out, vi_s, vrtxidx[face[i].data.vertex[j]]);
if (k & 1)
Expand Down
10 changes: 9 additions & 1 deletion code/AssetLib/glTF/glTFExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,12 @@ void glTFExporter::ExportMeshes()

// Variables needed for compression. BEGIN.
// Indices, not pointers - because pointer to buffer is changing while writing to it.
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
size_t idx_srcdata_begin = 0; // Index of buffer before writing mesh data. Also, index of begin of coordinates array in buffer.
size_t idx_srcdata_normal = SIZE_MAX;// Index of begin of normals array in buffer. SIZE_MAX - mean that mesh has no normals.
std::vector<size_t> idx_srcdata_tc;// Array of indices. Every index point to begin of texture coordinates array in buffer.
size_t idx_srcdata_ind;// Index of begin of coordinates indices array in buffer.
#endif
std::vector<size_t> idx_srcdata_tc;// Array of indices. Every index point to begin of texture coordinates array in buffer.
bool comp_allow;// Point that data of current mesh can be compressed.
// Variables needed for compression. END.

Expand Down Expand Up @@ -609,13 +611,17 @@ void glTFExporter::ExportMeshes()

/******************* Vertices ********************/
// If compression is used then you need parameters of uncompressed region: begin and size. At this step "begin" is stored.
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
if(comp_allow) idx_srcdata_begin = b->byteLength;
#endif

Ref<Accessor> v = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mVertices, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT, BufferViewTarget_ARRAY_BUFFER);
if (v) p.attributes.position.push_back(v);

/******************** Normals ********************/
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
if(comp_allow && (aim->mNormals != 0)) idx_srcdata_normal = b->byteLength;// Store index of normals array.
#endif

Ref<Accessor> n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT, BufferViewTarget_ARRAY_BUFFER);
if (n) p.attributes.normal.push_back(n);
Expand All @@ -640,7 +646,9 @@ void glTFExporter::ExportMeshes()
}

/*************** Vertices indices ****************/
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
idx_srcdata_ind = b->byteLength;// Store index of indices array.
#endif

if (aim->mNumFaces > 0) {
std::vector<IndicesType> indices;
Expand Down

0 comments on commit b1980a8

Please sign in to comment.