Skip to content

Commit

Permalink
rename componentBytes to bytesPerComponent in accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
recp committed Jan 26, 2024
1 parent 8b8fd5b commit 8dd26f3
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 79 deletions.
2 changes: 1 addition & 1 deletion include/ak/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef struct AkAccessor {
size_t byteStride; /* stride in bytes */
size_t byteLength; /* total bytes for this accessor */
uint32_t count; /* count to access buffer */
uint32_t componentBytes; /* component stride in bytes */
uint32_t bytesPerComponent; /* component stride in bytes */
AkComponentSize componentSize; /* vec1 | vec2 | vec3 | vec4 ... */
AkTypeId componentType; /* single component type */
uint32_t componentCount;
Expand Down
4 changes: 2 additions & 2 deletions src/bbox/mesh_prim.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ ak_bbox_mesh_prim(struct AkMeshPrimitive * __restrict prim) {
byteStride = acc->byteStride;

if (byteStride == 0)
byteStride = acc->componentBytes;
byteStride = acc->fillByteSize;

/* we must walk through indices if exists because source may contain
unrelated data and this will cause get wrong box
*/
Expand Down
2 changes: 1 addition & 1 deletion src/coord/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ak_changeCoordSysMesh(AkMesh * __restrict mesh,
if (acci->componentType == AKT_FLOAT) {
ak_coordCvtVectors(doc->coordSys,
buffi->data,
buffi->length / acci->componentBytes,
buffi->length / acci->bytesPerComponent,
newCoordSys);
}
mapi = mapi->next;
Expand Down
52 changes: 26 additions & 26 deletions src/io/common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ io_addInput(AkHeap * __restrict heap,

flist_sp_insert(&doc->lib.buffers, buff);

acc = ak_heap_calloc(heap, doc, sizeof(*acc));
acc->buffer = buff;
acc->byteLength = buff->length;
acc->byteStride = typeDesc->size * nComponents;
acc->componentSize = compSize;
acc->componentType = type;
acc->componentBytes = typeDesc->size * nComponents;
acc->componentCount = nComponents;
acc->fillByteSize = typeDesc->size * nComponents;
acc->count = (uint32_t)dctx->itemcount;
acc = ak_heap_calloc(heap, doc, sizeof(*acc));
acc->buffer = buff;
acc->byteLength = buff->length;
acc->byteStride = typeDesc->size * nComponents;
acc->componentSize = compSize;
acc->componentType = type;
acc->bytesPerComponent = typeDesc->size;
acc->componentCount = nComponents;
acc->fillByteSize = typeDesc->size * nComponents;
acc->count = (uint32_t)dctx->itemcount;

inp = ak_heap_calloc(heap, prim, sizeof(*inp));
inp->accessor = acc;
inp->semantic = sem;
inp->semanticRaw = ak_heap_strdup(heap, inp, semRaw);
inp->offset = offset;

inp = ak_heap_calloc(heap, prim, sizeof(*inp));
inp->accessor = acc;
inp->semantic = sem;
inp->semanticRaw = ak_heap_strdup(heap, inp, semRaw);
inp->offset = offset;

ak_retain(acc);

inp->next = prim->input;
Expand All @@ -112,16 +112,16 @@ io_acc(AkHeap * __restrict heap,
typeDesc = ak_typeDesc(type);
nComponents = (int)compSize;

acc = ak_heap_calloc(heap, doc, sizeof(*acc));
acc->buffer = buff;
acc->byteLength = buff->length;
acc->byteStride = typeDesc->size * nComponents;
acc->componentSize = compSize;
acc->componentType = type;
acc->componentBytes = typeDesc->size * nComponents;
acc->componentCount = nComponents;
acc->fillByteSize = typeDesc->size * nComponents;
acc->count = count;
acc = ak_heap_calloc(heap, doc, sizeof(*acc));
acc->buffer = buff;
acc->byteLength = buff->length;
acc->byteStride = typeDesc->size * nComponents;
acc->componentSize = compSize;
acc->componentType = type;
acc->bytesPerComponent = typeDesc->size;
acc->componentCount = nComponents;
acc->fillByteSize = typeDesc->size * nComponents;
acc->count = count;

return acc;
}
Expand Down
24 changes: 12 additions & 12 deletions src/io/dae/postscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,25 @@ dae_fixup_accessors(DAEState * __restrict dst) {
AkBuffer *newbuff;
AkDataParam *dp;
char *olditms, *newitms;
uint32_t i, j, count, dpoff, componentBytes;
uint32_t i, j, count, dpoff, bytesPerComponent;
size_t oldByteStride, newByteStride;

acc->componentType = (AkTypeId)(uintptr_t)ak_userData(buff);

if ((type = ak_typeDesc(acc->componentType)))
componentBytes = type->size;
bytesPerComponent = type->size;
else
goto cont;

count = acc->count;
acc->byteStride = accdae->stride * componentBytes;
acc->byteLength = count * accdae->stride * componentBytes;
acc->byteOffset = accdae->offset * componentBytes;
accdae->bound = accdae->stride;
count = acc->count;
acc->byteStride = accdae->stride * bytesPerComponent;
acc->byteLength = count * accdae->stride * bytesPerComponent;
acc->byteOffset = accdae->offset * bytesPerComponent;
accdae->bound = accdae->stride;

acc->fillByteSize = accdae->bound * componentBytes;
acc->componentCount = accdae->bound;
acc->componentBytes = componentBytes;
acc->fillByteSize = accdae->bound * bytesPerComponent;
acc->componentCount = accdae->bound;
acc->bytesPerComponent = bytesPerComponent;

/*--------------------------------------------------------------------*
Expand All @@ -270,7 +270,7 @@ dae_fixup_accessors(DAEState * __restrict dst) {
/* TODO: check param that has empty name */
if (acc->buffer && ak_refc(buff) > 1) {
oldByteStride = acc->byteStride;
newByteStride = accdae->bound * componentBytes;
newByteStride = accdae->bound * bytesPerComponent;
newbuff = ak_heap_calloc(heap, doc, sizeof(*newbuff));
newbuff->length = count * newByteStride;
newbuff->data = ak_heap_calloc(heap, newbuff, newbuff->length);
Expand All @@ -285,7 +285,7 @@ dae_fixup_accessors(DAEState * __restrict dst) {

while (dp) {
if (dp->name) {
memcpy(newitms + newByteStride * i + componentBytes * j++,
memcpy(newitms + newByteStride * i + bytesPerComponent * j++,
olditms + oldByteStride * i + dpoff,
dp->type.size);
}
Expand Down
22 changes: 11 additions & 11 deletions src/io/gltf/imp/core/accessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,22 @@ gltf_accessors(json_t * __restrict json,

/* prepare for min and max */
if (acc->componentSize < 5) {
bound = acc->componentSize;
acc->componentBytes = bound * componentLen;
acc->componentCount = bound;
bound = acc->componentSize;
acc->bytesPerComponent = componentLen;
acc->componentCount = bound;
} else {
bound = acc->componentSize >> 3;
acc->componentBytes = bound * componentLen;
acc->componentCount = bound;
bound = acc->componentSize >> 3;
acc->bytesPerComponent = componentLen;
acc->componentCount = bound;
}

acc->byteLength = acc->count * acc->componentBytes;
acc->fillByteSize = acc->componentBytes;
acc->byteLength = acc->bytesPerComponent * acc->count;
acc->fillByteSize = acc->bytesPerComponent * bound;

if (acc->componentSize != AK_COMPONENT_SIZE_UNKNOWN
&& acc->componentBytes > 0) {
&& acc->fillByteSize > 0) {
if ((it = accMap[k_gltf_min].object) && it->value) {
acc->min = ak_heap_alloc(heap, acc, acc->componentBytes);
acc->min = ak_heap_alloc(heap, acc, acc->fillByteSize);

if ((jarr = json_array(it))) {
jitem = jarr->base.value;
Expand All @@ -159,7 +159,7 @@ gltf_accessors(json_t * __restrict json,
}

if ((it = accMap[k_gltf_max].object) && it->value) {
acc->max = ak_heap_alloc(heap, acc, acc->componentBytes);
acc->max = ak_heap_alloc(heap, acc, acc->fillByteSize);

if ((jarr = json_array(it))) {
jitem = jarr->base.value;
Expand Down
3 changes: 2 additions & 1 deletion src/io/gltf/imp/core/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ gltf_meshes(json_t * __restrict jmesh,
AkGeometry *geom;
AkMesh *mesh;
AkObject *meshObj;
uint32_t mode;

mesh = ak_allocMesh(heap, lib, &geom);
meshObj = ak_objFrom(mesh);
Expand Down Expand Up @@ -133,7 +134,7 @@ gltf_meshes(json_t * __restrict jmesh,
|| !(indicesBuff = acc->buffer))
goto prim_next;

itemSize = acc->componentBytes;
itemSize = acc->bytesPerComponent;
count = acc->count;
indices = ak_heap_calloc(heap,
prim,
Expand Down
20 changes: 10 additions & 10 deletions src/io/obj/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ wobj_acc(WOState * __restrict wst,

flist_sp_insert(&wst->doc->lib.buffers, buff);

acc = ak_heap_calloc(heap, wst->doc, sizeof(*acc));
acc->buffer = buff;
acc->byteLength = buff->length;
acc->byteStride = typeDesc->size * nComponents;
acc->componentSize = compSize;
acc->componentType = type;
acc->componentBytes = typeDesc->size * nComponents;
acc->componentCount = nComponents;
acc->fillByteSize = typeDesc->size * nComponents;
acc->count = (uint32_t)dctx->itemcount;
acc = ak_heap_calloc(heap, wst->doc, sizeof(*acc));
acc->buffer = buff;
acc->byteLength = buff->length;
acc->byteStride = typeDesc->size * nComponents;
acc->componentSize = compSize;
acc->componentType = type;
acc->bytesPerComponent = typeDesc->size;
acc->componentCount = nComponents;
acc->fillByteSize = typeDesc->size * nComponents;
acc->count = (uint32_t)dctx->itemcount;

return acc;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/edit_buff.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ak_meshReserveBufferForInput(AkMesh * __restrict mesh,
buffid = input;
buffstate = ak_meshReserveBuffer(mesh,
buffid,
acci->componentBytes,
acci->bytesPerComponent,
acci->componentCount,
count);
buffi = buffstate->buff;
Expand Down
26 changes: 13 additions & 13 deletions src/mesh/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,21 @@ ak_meshPrimGenNormals(AkMeshPrimitive * __restrict prim) {
ak_setypeid(acc, AKT_ACCESSOR);


acc->componentCount = 3;
acc->count = count;
acc->componentType = AKT_FLOAT;
acc->componentSize = AK_COMPONENT_SIZE_VEC3;
acc->componentBytes = ak_typeDesc(acc->componentType)->size;
acc->byteStride = acc->componentCount * acc->componentBytes;
acc->fillByteSize = acc->byteStride;
acc->byteLength = acc->count * acc->byteStride;
acc->componentCount = 3;
acc->count = count;
acc->componentType = AKT_FLOAT;
acc->componentSize = AK_COMPONENT_SIZE_VEC3;
acc->bytesPerComponent = ak_typeDesc(acc->componentType)->size;
acc->byteStride = acc->componentCount * acc->bytesPerComponent;
acc->fillByteSize = acc->byteStride;
acc->byteLength = acc->count * acc->byteStride;


buff = ak_heap_calloc(heap, doc, sizeof(*buff));
buff->data = ak_heap_alloc(heap, buff, acc->byteLength);
buff->length = acc->byteLength;
buff = ak_heap_calloc(heap, doc, sizeof(*buff));
buff->data = ak_heap_alloc(heap, buff, acc->byteLength);
buff->length = acc->byteLength;

acc->buffer = buff;
acc->buffer = buff;

flist_sp_insert(&doc->lib.accessors, acc);
flist_sp_insert(&doc->lib.buffers, buff);
Expand Down
2 changes: 1 addition & 1 deletion src/morph/intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ ak_morphInspect(AkGeometry * __restrict baseMesh,
#undef ak__collectTargetInput

return AK_OK;
err:
err:
ak_free(view);
return AK_ERR;
}
Expand Down

0 comments on commit 8dd26f3

Please sign in to comment.