16-byte alignment
This commit is contained in:
parent
4afe4f3fbe
commit
6c13a83271
4
src/k3.c
4
src/k3.c
@ -170,7 +170,7 @@ struct k3Mdl *k3MdlCreate(size_t verts, size_t indices, size_t boneCount, vec3 *
|
||||
ret->anims = NULL;
|
||||
|
||||
if(k3IsSoftSkinning && pos && boneids && boneweights) {
|
||||
ret->cpuSkinning.pos = malloc(sizeof(*ret->cpuSkinning.pos) * verts);
|
||||
ret->cpuSkinning.pos = _mm_malloc(sizeof(*ret->cpuSkinning.pos) * verts, 16);
|
||||
memcpy(ret->cpuSkinning.pos, pos, sizeof(*ret->cpuSkinning.pos) * verts);
|
||||
|
||||
ret->cpuSkinning.boneids = malloc(sizeof(*ret->cpuSkinning.boneids) * verts * 4);
|
||||
@ -342,7 +342,7 @@ struct k3Mdl *k3MdlCopySubs(struct k3Mdl *src) {
|
||||
memcpy(dst->meshes, src->meshes, sizeof(*dst->meshes) * dst->meshCount);
|
||||
|
||||
dst->boneCount = src->boneCount;
|
||||
dst->invBind = malloc(sizeof(*dst->invBind) * dst->boneCount);
|
||||
dst->invBind = _mm_malloc(sizeof(*dst->invBind) * dst->boneCount, 16);
|
||||
memcpy(dst->invBind, src->invBind, sizeof(*dst->invBind) * dst->boneCount);
|
||||
dst->boneParents = malloc(sizeof(*dst->boneParents) * dst->boneCount);
|
||||
memcpy(dst->boneParents, src->boneParents, sizeof(*dst->boneParents) * dst->boneCount);
|
||||
|
@ -67,10 +67,10 @@ static void random_cone_vector(float coneAngle, vec3 output) {
|
||||
}
|
||||
|
||||
static void regenerate_model(struct k3CPUQuadParticles *this, vec3 cameraRight, vec3 cameraUp, vec3 cameraFront) {
|
||||
vec3 *vpos = calloc(sizeof(*vpos), 4 * this->capacity);
|
||||
uint8_t *vcols = calloc(4, 4 * this->capacity);
|
||||
vec2 *vuvs = calloc(sizeof(*vuvs), 4 * this->capacity);
|
||||
uint8_t *vnrms = calloc(3, 4 * this->capacity);
|
||||
vec3 *vpos = _mm_malloc(sizeof(*vpos) * 4 * this->capacity, 16);
|
||||
uint8_t *vcols = _mm_malloc(4 * 4 * this->capacity, 16);
|
||||
vec2 *vuvs = _mm_malloc(sizeof(*vuvs) * 4 * this->capacity, 16);
|
||||
uint8_t *vnrms = _mm_malloc(3 * 4 * this->capacity, 16);
|
||||
|
||||
vec3 halfRight, halfUp;
|
||||
glm_vec3_scale(cameraRight, 0.5, halfRight);
|
||||
@ -128,10 +128,10 @@ static void regenerate_model(struct k3CPUQuadParticles *this, vec3 cameraRight,
|
||||
|
||||
this->mdl->meshes[0].idxNumber = this->count * 6;
|
||||
|
||||
free(vpos);
|
||||
free(vcols);
|
||||
free(vuvs);
|
||||
free(vnrms);
|
||||
_mm_free(vpos);
|
||||
_mm_free(vcols);
|
||||
_mm_free(vuvs);
|
||||
_mm_free(vnrms);
|
||||
}
|
||||
|
||||
static void copy_particle(struct k3CPUQuadParticles *this, size_t from, size_t to) {
|
||||
|
@ -5,6 +5,19 @@
|
||||
#include"k3.h"
|
||||
|
||||
struct k3CPUQuadParticles {
|
||||
vec4 colorStart;
|
||||
vec4 colorEnd;
|
||||
|
||||
vec3 origin;
|
||||
vec3 gravity;
|
||||
vec3 emissionConeDirection;
|
||||
float emissionRate;
|
||||
float emissionConeAngle;
|
||||
float particleLifetime;
|
||||
|
||||
bool emissionEnabled;
|
||||
float emissionLifetime;
|
||||
|
||||
size_t capacity;
|
||||
size_t count;
|
||||
vec3 *positions;
|
||||
@ -13,19 +26,6 @@ struct k3CPUQuadParticles {
|
||||
float *lifetimes;
|
||||
|
||||
struct k3Mdl *mdl;
|
||||
|
||||
vec4 colorStart;
|
||||
vec4 colorEnd;
|
||||
|
||||
vec3 origin;
|
||||
vec3 gravity;
|
||||
float emissionRate;
|
||||
vec3 emissionConeDirection;
|
||||
float emissionConeAngle;
|
||||
float particleLifetime;
|
||||
|
||||
bool emissionEnabled;
|
||||
float emissionLifetime;
|
||||
};
|
||||
|
||||
void k3CPUQuadParticlesInit(struct k3CPUQuadParticles*, struct k3Mat*);
|
||||
|
Loading…
Reference in New Issue
Block a user