star-meshtool

Mesh transformation
git clone git://git.meso-star.fr/star-meshtool.git
Log | Files | Refs | README | LICENSE

commit e451d349a012369e4296721f1b6f8a6b9b45ecbd
parent 8d24ce4f75db833b07d00c510237847898e9fbf8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 19 Nov 2025 10:02:25 +0100

Correction of the order of transformations

The transformations were applied in reverse order to the order in which
they were read from the command line, whereas it should have been the
other way around.

Diffstat:
Msrc/mtool_args.c | 31+++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/mtool_args.c b/src/mtool_args.c @@ -57,13 +57,14 @@ apply_scale(struct mtool_args* args, const char* str) if(res == RES_OK && len != 3) res = RES_BAD_ARG; if(res != RES_OK) goto error; - /* | A, D G J | | Sx 0 0 0 | | A*Sx D*Sy G*Sz J | - * M = | B, E H K | * | 0 Sy 0 0 | = | B*Sx E*Sy H*Sz K | - * | C, F I L | | 0 0 Sz 0 | | C*Sx F*Sy I*Sz L | - * | 0, 0 0 1 | | 0 0 0 1 | | 0 0 0 1 | */ - d3_muld(args->transform+0, args->transform+0, scale[0]); - d3_muld(args->transform+3, args->transform+3, scale[1]); - d3_muld(args->transform+6, args->transform+6, scale[2]); + /* | Sx 0 0 0 | | A, D G J | | A*Sx D*Sx G*Sx J*Sx | + * M = | 0 Sy 0 0 | * | B, E H K | = | B*Sy E*Sy H*Sy K*Sy | + * | 0 0 Sz 0 | | C, F I L | | C*Sz F*Sz I*Sz L*Sz | + * | 0 0 0 1 | | 0, 0 0 1 | | 0 0 0 1 | */ + d3_mul(args->transform+0, args->transform+0, scale); + d3_mul(args->transform+3, args->transform+3, scale); + d3_mul(args->transform+6, args->transform+6, scale); + d3_mul(args->transform+9, args->transform+9, scale); exit: return res; @@ -75,8 +76,6 @@ static res_T apply_translation(struct mtool_args* args, const char* str) { double translation[3] = {0,0,0}; - double tmp[3] = {0,0,0}; - double vec[3] = {0,0,0}; size_t len = 0; res_T res = RES_OK; @@ -86,15 +85,11 @@ apply_translation(struct mtool_args* args, const char* str) if(res == RES_OK && len != 3) res = RES_BAD_ARG; if(res != RES_OK) goto error; - /* | A D G J | | 1 0 0 Tx | | A D G (A*Tx + D*Ty + G*Tz + J) | - * M = | B E H K | * | 0 1 0 Ty | = | B E H (B*Tx + E*Ty + H*Tz + K) | - * | C F I L | | 0 0 1 Tz | | C F I (C*Tx + F*Ty + I*Tz + L) | - * | 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 | */ - d3_muld(vec, args->transform+0, translation[0]); - d3_add(vec, vec, d3_muld(tmp, args->transform+3, translation[1])); - d3_add(vec, vec, d3_muld(tmp, args->transform+6, translation[2])); - d3_add(vec, vec, args->transform+9); - d3_set(args->transform+9, vec); + /* | 1 0 0 Tx | | A D G J | | A D G (Tx + J) | + * M = | 0 1 0 Ty | * | B E H K | = | B E H (Ty + K) | + * | 0 0 1 Tz | | C F I L | | C F I (Tz + L) | + * | 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 | */ + d3_add(args->transform+9, args->transform+9, translation); exit: return res;