Compare commits
6 Commits
9bc549546f
...
69f355eae4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
69f355eae4 | ||
![]() |
676127c41f | ||
![]() |
9ae4abbb56 | ||
![]() |
0461199e64 | ||
![]() |
05d0c75937 | ||
![]() |
1ee7d6c26e |
2
src/k3.c
2
src/k3.c
@ -283,7 +283,7 @@ void k3MdlUpdateNrm(struct k3Mdl *mdl, uint8_t *nrm) {
|
||||
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, mdl->offN, 3 * mdl->verts, nrm);
|
||||
}
|
||||
|
||||
void k3MdlAddMesh(struct k3Mdl *mdl, struct k3Mat *mat, uint16_t idxStart, uint16_t idxNumber) {
|
||||
void k3MdlAddMesh(struct k3Mdl *mdl, struct k3Mat *mat, uint32_t idxStart, uint32_t idxNumber) {
|
||||
mdl->meshes = realloc(mdl->meshes, sizeof(*mdl->meshes) * (mdl->meshCount + 1));
|
||||
struct k3Mesh *mehs = &mdl->meshes[mdl->meshCount++];
|
||||
mehs->idxStart = idxStart;
|
||||
|
4
src/k3.h
4
src/k3.h
@ -146,7 +146,7 @@ struct k3Light {
|
||||
};
|
||||
|
||||
struct k3Mesh {
|
||||
uint16_t idxStart, idxNumber;
|
||||
uint32_t idxStart, idxNumber;
|
||||
struct k3Mat mat;
|
||||
};
|
||||
|
||||
@ -159,7 +159,7 @@ void k3StorageUnref(struct k3Storage*);
|
||||
struct k3Mdl;
|
||||
struct k3Mdl *k3MdlCreate(size_t verts, size_t indices, size_t boneCount, vec3 *pos, uint8_t *nrm, float *uvs, uint8_t *cols, uint8_t *boneids, uint16_t *boneweights, uint16_t *inds, mat4 *invBind, uint8_t *boneParents);
|
||||
void k3MdlUpdatePos(struct k3Mdl *mdl, vec3 *pos);
|
||||
void k3MdlAddMesh(struct k3Mdl*, struct k3Mat*, uint16_t idxStart, uint16_t idxNumber);
|
||||
void k3MdlAddMesh(struct k3Mdl*, struct k3Mat*, uint32_t idxStart, uint32_t idxNumber);
|
||||
struct k3Mesh *k3MdlGetMeshes(struct k3Mdl*, size_t *count);
|
||||
void k3MdlAddAnim(struct k3Mdl*, struct k3AnimationFountain*);
|
||||
struct k3AnimationFountain *k3MdlGetAnim(struct k3Mdl*, uint16_t id);
|
||||
|
@ -153,13 +153,15 @@ void k3FontDraw(struct k3Font *this, float xStart, float yStart, float sz, const
|
||||
break;
|
||||
}
|
||||
|
||||
lineLength++;
|
||||
|
||||
struct k3FontGlyph *g = k3FontGetGlyph(this, cp2);
|
||||
if(g) {
|
||||
if(lineWidth + g->width * this->lineScale * sz > wall) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lineLength++;
|
||||
if(g) {
|
||||
lineWidth += g->xadvance * this->lineScale * sz;
|
||||
}
|
||||
}
|
||||
@ -189,7 +191,7 @@ void k3FontDraw(struct k3Font *this, float xStart, float yStart, float sz, const
|
||||
size_t texH = this->texH;
|
||||
|
||||
k3BatchAdd(tex,
|
||||
(struct k3RectF) {(float) g->x / texW, (float) g->y / texH, (float) g->width / texW, (float) g->height / texH},
|
||||
(struct k3RectF) {(float) (g->x + 0.5) / texW, (float) (g->y + 0.5) / texH, (float) (g->width - 1) / texW, (float) (g->height - 1) / texH},
|
||||
(struct k3RectF) {
|
||||
x + g->xoffset * this->lineScale * sz,
|
||||
y + ((-g->height - g->yoffset) * this->lineScale + 1) * sz,
|
||||
|
27
src/k3menu.c
27
src/k3menu.c
@ -100,6 +100,15 @@ static bool linear_arrange(struct k3MEvent *ev, uint8_t *ud) {
|
||||
c->x = o->x + padding[3];
|
||||
c->y = y;
|
||||
|
||||
struct k3MProperty *prop = k3MFindProperty(c, k3M_PROP_WIDTH, true);
|
||||
if(prop) {
|
||||
if(prop->units[0] == k3M_UNIT_ABSOLUTE) {
|
||||
c->w = prop->f[0];
|
||||
} else if(prop->units[0] == k3M_UNIT_PROPORTION) {
|
||||
c->w = o->w * prop->f[0];
|
||||
}
|
||||
}
|
||||
|
||||
if(c->w > o->w - padding[1] - padding[3]) {
|
||||
c->w = o->w - padding[1] - padding[3];
|
||||
}
|
||||
@ -245,7 +254,7 @@ static bool label_draw(struct k3MEvent *ev, uint8_t *ud) {
|
||||
|
||||
if(va != k3M_ALIGN_TOP) {
|
||||
struct k3RectF txtsz;
|
||||
k3FontSz(this->font, this->sz, this->txt, this->w, &txtsz);
|
||||
k3FontSz(this->font, sz, this->txt, this->w, &txtsz);
|
||||
if(va == k3M_ALIGN_CENTER) {
|
||||
y += (this->h - txtsz.h) / 2;
|
||||
} else if(va == k3M_ALIGN_BOTTOM) {
|
||||
@ -262,8 +271,12 @@ static bool label_draw(struct k3MEvent *ev, uint8_t *ud) {
|
||||
static bool label_measure(struct k3MEvent *ev, uint8_t *ud) {
|
||||
struct k3MLabel *this = (void*) ev->target;
|
||||
|
||||
float sz = this->sz;
|
||||
struct k3MProperty *prop = k3MFindProperty(this, k3M_PROP_FONT_SIZE, false);
|
||||
if(prop) sz = prop->f[0];
|
||||
|
||||
struct k3RectF txtsz;
|
||||
k3FontSz(this->font, this->sz, this->txt, -1, &txtsz);
|
||||
k3FontSz(this->font, sz, this->txt, -1, &txtsz);
|
||||
|
||||
this->w = ceilf(txtsz.w);
|
||||
this->h = ceilf(txtsz.h);
|
||||
@ -273,8 +286,12 @@ static bool label_measure(struct k3MEvent *ev, uint8_t *ud) {
|
||||
static bool label_set_height_from_width(struct k3MEvent *ev, uint8_t *ud) {
|
||||
struct k3MLabel *this = (void*) ev->target;
|
||||
|
||||
float sz = this->sz;
|
||||
struct k3MProperty *prop = k3MFindProperty(this, k3M_PROP_FONT_SIZE, false);
|
||||
if(prop) sz = prop->f[0];
|
||||
|
||||
int16_t pxsz[2];
|
||||
immdraw_font_size(this->font, this->sz, this->txt, this->w, pxsz);
|
||||
immdraw_font_size(this->font, sz, this->txt, this->w, pxsz);
|
||||
|
||||
this->h = pxsz[1];
|
||||
|
||||
@ -297,7 +314,7 @@ struct k3MLabel *k3MLabel(struct k3Font *font, float sz, const char *txt) {
|
||||
int k3MRemoveChild(struct k3MObj *parent, struct k3MObj *child) {
|
||||
for(size_t i = 0; i < parent->childCount; i++) {
|
||||
if(parent->children[i] == child) {
|
||||
memcpy(&parent->children[i], &parent->children[i + 1], sizeof(*parent->children) * (parent->childCount - i - 1));
|
||||
memmove(&parent->children[i], &parent->children[i + 1], sizeof(*parent->children) * (parent->childCount - i - 1));
|
||||
|
||||
parent->childCount--;
|
||||
|
||||
@ -455,7 +472,7 @@ static bool screen_ev(struct k3MEvent *ev, uint8_t *ud) {
|
||||
|
||||
}
|
||||
|
||||
for(intmax_t i = this->childCount - 1; i >= 0; i--) {
|
||||
for(intmax_t i = 0; i < this->childCount; i++) {
|
||||
if(!this->children[i]->invisible) {
|
||||
struct k3MEvent newev = *ev;
|
||||
newev.kind = k3M_EVENTKIND_CAPTURE;
|
||||
|
Loading…
Reference in New Issue
Block a user