Skip to content

Commit

Permalink
#123 Fix somebugs on modify gizmos & transform editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Jun 14, 2022
1 parent 626a54e commit 5b516fe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Documents/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
## Git flow
### Feature
- If you commit code for feature, open an issue ex: #282. Create your branch name: **`feature/#282-your-branch-name`** (All characters is lowercase and character '-' instead space ' ')
- Commit message: **`feat: #282 To do some thing`**
- Commit message: **`#282 To do some thing`**
- If your commit message too long
```
feat: #282 To do some thing
#282 To do some thing
Do some thing 1
Do some thing 2
...
```
### Bug
- Open an issue ex: #283. Create your branch name: **`bug/#283-your-bug-name`**
- Commit message: **`fix: #283 To do fix some thing`**
- Commit message: **`#283 To do fix some thing`**

Remember tag your issues id ex: #282 on your commit message, and branch name
## Code style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ namespace Skylicht
CSubject<core::vector3df>* value = (CSubject<core::vector3df>*)subject;
const core::vector3df& pos = value->get();

m_position = pos;

x->set(pos.X);
y->set(pos.Y);
z->set(pos.Z);
Expand All @@ -108,36 +110,36 @@ namespace Skylicht
ui->addNumberInput(layout, L"Y", &Y, 0.01f);
ui->addNumberInput(layout, L"Z", &Z, 0.01f);

X.addObserver(new CObserver([&, pos = &m_position, g = m_gizmos](ISubject* subject, IObserver* from)
X.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
pos->X = value->get();
m_position.X = value->get();
updateMatrix();
g->setPosition(*pos);
g->setPosition(m_position);
}
}), true);

Y.addObserver(new CObserver([&, pos = &m_position, g = m_gizmos](ISubject* subject, IObserver* from)
Y.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
pos->Y = value->get();
m_position.Y = value->get();
updateMatrix();
g->setPosition(*pos);
g->setPosition(m_position);
}
}), true);

Z.addObserver(new CObserver([&, pos = &m_position, g = m_gizmos](ISubject* subject, IObserver* from)
Z.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
pos->Z = value->get();
m_position.Z = value->get();
updateMatrix();
g->setPosition(*pos);
g->setPosition(m_position);
}
}), true);

Expand All @@ -154,6 +156,8 @@ namespace Skylicht
core::vector3df rot;
value->get().toEuler(rot);

m_rotate = rot;

x->set(rot.X * core::RADTODEG);
y->set(rot.Y * core::RADTODEG);
z->set(rot.Z * core::RADTODEG);
Expand All @@ -169,36 +173,36 @@ namespace Skylicht
ui->addNumberInput(layout, L"Y", &RotateY, 0.1f);
ui->addNumberInput(layout, L"Z", &RotateZ, 0.1f);

RotateX.addObserver(new CObserver([&, rot = &m_rotate, g = m_gizmos](ISubject* subject, IObserver* from)
RotateX.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
rot->X = value->get();
m_rotate.X = value->get();
updateMatrix();
g->setRotation(*rot);
g->setRotation(m_rotate);
}
}), true);

RotateY.addObserver(new CObserver([&, rot = &m_rotate, g = m_gizmos](ISubject* subject, IObserver* from)
RotateY.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
rot->Y = value->get();
m_rotate.Y = value->get();
updateMatrix();
g->setRotation(*rot);
g->setRotation(m_rotate);
}
}), true);

RotateZ.addObserver(new CObserver([&, rot = &m_rotate, g = m_gizmos](ISubject* subject, IObserver* from)
RotateZ.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
rot->Z = value->get();
m_rotate.Z = value->get();
updateMatrix();
g->setRotation(*rot);
g->setRotation(m_rotate);
}
}), true);

Expand All @@ -214,6 +218,8 @@ namespace Skylicht
CSubject<core::vector3df>* value = (CSubject<core::vector3df>*)subject;
const core::vector3df& scale = value->get();

m_scale = scale;

x->set(scale.X);
y->set(scale.Y);
z->set(scale.Z);
Expand All @@ -229,36 +235,36 @@ namespace Skylicht
ui->addNumberInput(layout, L"Y", &ScaleY, 0.01f);
ui->addNumberInput(layout, L"Z", &ScaleZ, 0.01f);

ScaleX.addObserver(new CObserver([&, scale = &m_scale, g = m_gizmos](ISubject* subject, IObserver* from)
ScaleX.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
scale->X = value->get();
m_scale.X = value->get();
updateMatrix();
g->setScale(*scale);
g->setScale(m_scale);
}
}), true);

ScaleY.addObserver(new CObserver([&, scale = &m_scale, g = m_gizmos](ISubject* subject, IObserver* from)
ScaleY.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
scale->Y = value->get();
m_scale.Y = value->get();
updateMatrix();
g->setScale(*scale);
g->setScale(m_scale);
}
}), true);

ScaleZ.addObserver(new CObserver([&, scale = &m_scale, g = m_gizmos](ISubject* subject, IObserver* from)
ScaleZ.addObserver(new CObserver([&, g = m_gizmos](ISubject* subject, IObserver* from)
{
if (from != g)
{
CSubject<float>* value = (CSubject<float>*) subject;
scale->Z = value->get();
m_scale.Z = value->get();
updateMatrix();
g->setScale(*scale);
g->setScale(m_scale);
}
}), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ namespace Skylicht

void CWorldTransformDataGizmos::onEnable()
{

getSubjectTransformGizmos().set(m_lastType);
getSubjectTransformGizmos().notify(this);
}

void CWorldTransformDataGizmos::onRemove()
Expand Down

0 comments on commit 5b516fe

Please sign in to comment.