armory3d / armory3d/armory

Serious scaling issues when objects are parented

Open
#2,211 10 comments 3 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
3.3k
Forks
353
Avg merge
3d 16h
Merged PRs (30d)
1

Description

**Description**

I encountered a major scaling issue when I was trying to understand transforms in Armory. In the test scene I have four cubes. Two of them have a parent child relationship, and the other two dont. The green cubes are scaled by 0.5 along the X axis. The red cubes are simply rotated along z axis by 45 degrees. The only diffference between the two sets of cubes is parenting. Note that scaling and rotations were not "applied" in Blender.

![Capture3](https://user-images.githubusercontent.com/55564981/119336487-00384e00-bc8e-11eb-9c0a-309c8a584168.PNG)

The image above shows parented cubes on the right and un-parented ones on the left.

When viewed from orthographic projection, here is the comparison between Blender and Armory

![Picture1](https://user-images.githubusercontent.com/55564981/119337565-4641e180-bc8f-11eb-8ed0-63e065b56a79.png)

From the image, the parented object has wrong scaling. While the unparented one looks correct.

However, when I checked the local transform of the objects in blender and Armory, they were a bit different:
![image](https://user-images.githubusercontent.com/55564981/119338217-04fe0180-bc90-11eb-8922-3c1b2dffb38f.png)
```
arm/MyTrait.hx:18: Cube.002 :
arm/MyTrait.hx:19: Local Transform =
arm/MyTrait.hx:84: Loc:
arm/MyTrait.hx:85: (0, 0, 3, 1)
arm/MyTrait.hx:86: Rot
arm/MyTrait.hx:87: 0, 0, -0.36288262477061145, 0.9318348569567418
arm/MyTrait.hx:88: Scl
arm/MyTrait.hx:89: (1.5683433228513, 1.5683434814930588, 1, 1)
```
The differences were that:
1. The local rotation quaternion (`object.transform.rot`) in Armory was not normalized.
2. The local scale (`object.transform.scale`) in Armory was different form that of Blender

**To Reproduce**
Use the provided blend file and run the project.

**Expected behavior**
The scaling of objects must be proper, even if object scaling is not applied beforehand.

**System**
Blender: 293
Armory: v2021.5 ($Id: 99497c80048d5b0614144ab4b87fb2303e416be2 $)
OS: Windows10

**Test File**
[ScaleRotBugTestFile.zip](https://github.com/armory3d/armory/files/6531903/ScaleRotBugTestFile.zip)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided ScaleRotBugTestFile.zip and run the project to reproduce the parented-versus-unparented scaling difference. Inspect the transform values reported from arm/MyTrait.hx, especially local rotation and scale, and compare them with Blender. Done means parented objects retain proper scaling when Blender transforms are unapplied and the local rotation is normalized.

Written by the indexing model from the issue text.

Assessment

Tech stack
blender
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.