clean up
parent
f6720271cb
commit
b8e39b58d1
|
@ -367,7 +367,7 @@ struct Object {
|
|||
//! An accessor provides a typed view into a BufferView or a subset of a BufferView
|
||||
//! similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer.
|
||||
struct Accessor : public Object {
|
||||
struct Sparse; //wangyi 0506
|
||||
struct Sparse;
|
||||
Ref<BufferView> bufferView; //!< The ID of the bufferView. (required)
|
||||
size_t byteOffset; //!< The offset relative to the start of the bufferView in bytes. (required)
|
||||
ComponentType componentType; //!< The datatype of components in the attribute. (required)
|
||||
|
@ -375,7 +375,7 @@ struct Accessor : public Object {
|
|||
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
|
||||
std::vector<double> max; //!< Maximum value of each component in this attribute.
|
||||
std::vector<double> min; //!< Minimum value of each component in this attribute.
|
||||
std::unique_ptr<Sparse> sparse; //wangyi 0506
|
||||
std::unique_ptr<Sparse> sparse;
|
||||
|
||||
unsigned int GetNumComponents();
|
||||
unsigned int GetBytesPerComponent();
|
||||
|
@ -387,7 +387,6 @@ struct Accessor : public Object {
|
|||
void ExtractData(T *&outData);
|
||||
|
||||
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
||||
//wangyi 0506
|
||||
void WriteSparseValues(size_t count, const void *src_data, size_t src_dataStride);
|
||||
void WriteSparseIndices(size_t count, const void *src_idx, size_t src_idxStride);
|
||||
|
||||
|
@ -430,7 +429,6 @@ struct Accessor : public Object {
|
|||
Accessor() {}
|
||||
void Read(Value &obj, Asset &r);
|
||||
|
||||
//wangyi 0506
|
||||
//sparse
|
||||
struct Sparse {
|
||||
size_t count;
|
||||
|
@ -577,7 +575,6 @@ struct BufferView : public Object {
|
|||
BufferViewTarget target; //! The target that the WebGL buffer should be bound to.
|
||||
|
||||
void Read(Value &obj, Asset &r);
|
||||
//wangyi 0506
|
||||
uint8_t *GetPointer(size_t accOffset);
|
||||
};
|
||||
|
||||
|
|
|
@ -550,7 +550,6 @@ inline void BufferView::Read(Value &obj, Asset &r) {
|
|||
byteStride = MemberOrDefault(obj, "byteStride", 0u);
|
||||
}
|
||||
|
||||
//wangyi 0506
|
||||
inline uint8_t *BufferView::GetPointer(size_t accOffset) {
|
||||
if (!buffer) return 0;
|
||||
uint8_t *basePtr = buffer->GetPointer();
|
||||
|
@ -571,7 +570,6 @@ inline uint8_t *BufferView::GetPointer(size_t accOffset) {
|
|||
// struct Accessor
|
||||
//
|
||||
|
||||
//wangyi 0506
|
||||
inline void Accessor::Sparse::PopulateData(size_t numBytes, uint8_t *bytes) {
|
||||
if (bytes) {
|
||||
data.assign(bytes, bytes + numBytes);
|
||||
|
@ -610,7 +608,7 @@ inline void Accessor::Sparse::PatchData(unsigned int elementSize) {
|
|||
pIndices += indexSize;
|
||||
}
|
||||
}
|
||||
// wangyi 0506
|
||||
|
||||
inline void Accessor::Read(Value &obj, Asset &r) {
|
||||
|
||||
if (Value *bufferViewVal = FindUInt(obj, "bufferView")) {
|
||||
|
@ -624,7 +622,6 @@ inline void Accessor::Read(Value &obj, Asset &r) {
|
|||
const char *typestr;
|
||||
type = ReadMember(obj, "type", typestr) ? AttribType::FromString(typestr) : AttribType::SCALAR;
|
||||
|
||||
//wangyi 0506
|
||||
if (Value *sparseValue = FindObject(obj, "sparse")) {
|
||||
sparse.reset(new Sparse);
|
||||
// count
|
||||
|
@ -674,7 +671,6 @@ inline unsigned int Accessor::GetElementSize() {
|
|||
return GetNumComponents() * GetBytesPerComponent();
|
||||
}
|
||||
|
||||
// wangyi 0506
|
||||
inline uint8_t *Accessor::GetPointer() {
|
||||
if (sparse)
|
||||
return sparse->data.data();
|
||||
|
@ -732,8 +728,6 @@ void Accessor::ExtractData(T *&outData)
|
|||
|
||||
const size_t targetElemSize = sizeof(T);
|
||||
ai_assert(elemSize <= targetElemSize);
|
||||
|
||||
//wangyi 0506
|
||||
ai_assert(count * stride <= (bufferView ? bufferView->byteLength : sparse->data.size()));
|
||||
|
||||
outData = new T[count];
|
||||
|
@ -759,7 +753,6 @@ inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t sr
|
|||
CopyData(_count, src, src_stride, dst, dst_stride);
|
||||
}
|
||||
|
||||
//wangyi 0506
|
||||
inline void Accessor::WriteSparseValues(size_t _count, const void *src_data, size_t src_dataStride) {
|
||||
if (!sparse)
|
||||
return;
|
||||
|
@ -774,7 +767,6 @@ inline void Accessor::WriteSparseValues(size_t _count, const void *src_data, siz
|
|||
CopyData(_count, value_src, src_dataStride, value_dst, value_dst_stride);
|
||||
}
|
||||
|
||||
//wangyi 0506
|
||||
inline void Accessor::WriteSparseIndices(size_t _count, const void *src_idx, size_t src_idxStride) {
|
||||
if (!sparse)
|
||||
return;
|
||||
|
|
|
@ -107,7 +107,6 @@ namespace glTF2 {
|
|||
|
||||
inline void Write(Value& obj, Accessor& a, AssetWriter& w)
|
||||
{
|
||||
//wangyi 0506
|
||||
if (a.bufferView) {
|
||||
obj.AddMember("bufferView", a.bufferView->index, w.mAl);
|
||||
obj.AddMember("byteOffset", (unsigned int)a.byteOffset, w.mAl);
|
||||
|
@ -125,7 +124,6 @@ namespace glTF2 {
|
|||
obj.AddMember("count", (unsigned int)a.count, w.mAl);
|
||||
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
|
||||
|
||||
// wangyi 0506
|
||||
if (a.sparse) {
|
||||
Value sparseValue;
|
||||
sparseValue.SetObject();
|
||||
|
|
|
@ -207,7 +207,6 @@ inline void SetAccessorRange(ComponentType compType, Ref<Accessor> acc, void* da
|
|||
}
|
||||
}
|
||||
|
||||
// wangyi 0506
|
||||
// compute the (data-dataBase), store the non-zero data items
|
||||
template <typename T>
|
||||
size_t NZDiff(void *data, void *dataBase, size_t count, unsigned int numCompsIn, unsigned int numCompsOut, void *&outputNZDiff, void *&outputNZIdx) {
|
||||
|
@ -271,7 +270,7 @@ inline size_t NZDiff(ComponentType compType, void *data, void *dataBase, size_t
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
// wangyi 0506
|
||||
|
||||
inline Ref<Accessor> ExportDataSparse(Asset &a, std::string &meshName, Ref<Buffer> &buffer,
|
||||
size_t count, void *data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, BufferViewTarget target = BufferViewTarget_NONE, void *dataBase = 0) {
|
||||
if (!count || !data) {
|
||||
|
@ -974,13 +973,13 @@ void glTF2Exporter::ExportMeshes()
|
|||
for (unsigned int vt = 0; vt < pAnimMesh->mNumVertices; ++vt) {
|
||||
pPositionDiff[vt] = pAnimMesh->mVertices[vt] - aim->mVertices[vt];
|
||||
}
|
||||
/*Ref<Accessor> vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pPositionDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);*/
|
||||
//wangyi 0506
|
||||
Ref<Accessor> vec = ExportDataSparse(*mAsset, meshId, b,
|
||||
Ref<Accessor> vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pPositionDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
/* sparse
|
||||
Ref<Accessor> vec = ExportDataSparse(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pPositionDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);*/
|
||||
if (vec) {
|
||||
p.targets[am].position.push_back(vec);
|
||||
}
|
||||
|
@ -993,13 +992,13 @@ void glTF2Exporter::ExportMeshes()
|
|||
for (unsigned int vt = 0; vt < pAnimMesh->mNumVertices; ++vt) {
|
||||
pNormalDiff[vt] = pAnimMesh->mNormals[vt] - aim->mNormals[vt];
|
||||
}
|
||||
/*Ref<Accessor> vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pNormalDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);*/
|
||||
//wangyi 0506
|
||||
Ref<Accessor> vec = ExportData(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pNormalDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
/* sparse
|
||||
Ref<Accessor> vec = ExportDataSparse(*mAsset, meshId, b,
|
||||
pAnimMesh->mNumVertices, pNormalDiff,
|
||||
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);*/
|
||||
if (vec) {
|
||||
p.targets[am].normal.push_back(vec);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue