07th-mod / 07th-mod/higurashi-assembly
Non-zero "originx" argument breaks image scaling
- Langage dominant
- C#
- Étoiles
- 12
- Forks
- 12
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
## Problem Description
I was looking at the code which handles scaling images to fit on the screen (to implement a feature related to letterboxing), and I noticed that there are two "CreateMesh" functions - see this [github code link](https://github.com/07th-mod/higurashi-assembly/blob/c2c64a6b977549efb199a44f726c530a1b0e9f93/Assets.Scripts.Core.Scene/Layer.cs#L873-L897)
### CreateMesh(..., Vector2 origin, ...)
- Used when the draw call is has a valid value for "origin", which boils down to setting the `originx` parameter to a nonzero value in draw calls in the game script.
- I think this function is nearly never used, as we don't ever set `originx` to anything other than zero
- I think this function is broken, due to using integer scaling function rather than float, unless the "only integer scaling" is intentional.
- For example, if the image height is 800, and it gets clamped to 480, then `scaling_factor = 800 / 480 = 0`, so `newWidth = scaling_factor * oldWidth = 0 * oldWidth = 0` and the image doesn't show at all...
- Only certain draw functions are affected. I think these are affected:
- DrawBustshotWithFiltering(...)
- DrawSprite(...)
- MODDrawCharacterWithFiltering(...)
### CreateMesh(..., LayerAlignment alignment, ...)
- Used when the draw call has 'origin' set to null
- Scaling is performed correctly
- This function is used most of the time when drawing everything
Note that the exact implementation of these functions are different depending on the chapter, refer to [#141 - Image letterboxing inconsistent between chapters ](https://github.com/07th-mod/higurashi-assembly/issues/141) for more details. However, all implementations of the `Vector2 origin` have the same integer scaling.
## Testing
I did do a quick test and setting originx non-zero did seem to break the image, but my testing wasn't very thorough.
## TODO
As changing this may affect everything in the whole engine, and we have so many mod options, I probably won't fix it.
- [ ] Ask orian if the `originx` argument is ever deliberately used
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Le problème pointe vers les lignes 873-897 de Layer.cs. Examinez les deux fonctions CreateMesh, en vous concentrant sur celle qui utilise Vector2 origin. Vérifiez comment le scaling_factor est calculé (division entière vs division flottante). Testez en définissant originx sur une valeur non nulle dans les appels de dessin concernés comme DrawBustshotWithFiltering pour voir si les images disparaissent. Vérifiez sur différents chapitres car les implémentations varient.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- unity
- Domaine
- computer-graphics, game-dev
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100