Skip to content

Commit 7199be7

Browse files
committed
Particle: Update billboard for some case
1 parent 668668a commit 7199be7

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

Projects/Skylicht/Components/ParticleSystem/CParticleRenderer.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,11 @@ namespace Skylicht
9797
modelView.getInversePrimitive(invModelView); // wont work for odd modelview matrices (but should happen in very special cases)
9898
}
9999

100-
core::vector3df look(invModelView[8], invModelView[9], invModelView[10]);
101-
core::vector3df up(invModelView[4], invModelView[5], invModelView[6]);
100+
m_billboardLook.set(invModelView[8], invModelView[9], invModelView[10]);
101+
m_billboardUp.set(invModelView[4], invModelView[5], invModelView[6]);
102102

103-
look.normalize();
104-
up.normalize();
105-
106-
CShaderParticle::setViewUp(up);
107-
CShaderParticle::setViewLook(look);
103+
m_billboardLook.normalize();
104+
m_billboardUp.normalize();
108105

109106
CEntity** entities = m_group->getEntities();
110107
int numEntity = m_group->getEntityCount();
@@ -167,6 +164,7 @@ namespace Skylicht
167164
for (u32 i = 0, n = data->AllGroups.size(); i < n; i++)
168165
{
169166
CGroup* g = groups[i];
167+
170168
if (g->getCurrentParticleCount() > 0 && g->Visible)
171169
{
172170
IRenderer* renderer = g->getRenderer();
@@ -210,6 +208,17 @@ namespace Skylicht
210208
IMeshBuffer* buffer = NULL;
211209
IRenderer* renderer = group->getRenderer();
212210

211+
if (group->UseOrientationAsBillboard)
212+
{
213+
CShaderParticle::setViewUp(group->OrientationUp);
214+
CShaderParticle::setViewLook(group->OrientationNormal);
215+
}
216+
else
217+
{
218+
CShaderParticle::setViewUp(m_billboardUp);
219+
CShaderParticle::setViewLook(m_billboardLook);
220+
}
221+
213222
if (renderer->useInstancing() == true)
214223
{
215224
CParticleInstancing* instancing = group->getIntancing();

Projects/Skylicht/Components/ParticleSystem/CParticleRenderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace Skylicht
4545
CEntityGroup* m_group;
4646
core::matrix4 m_transform;
4747

48+
core::vector3df m_billboardUp;
49+
core::vector3df m_billboardLook;
4850
public:
4951
CParticleRenderer();
5052

Projects/Skylicht/Components/ParticleSystem/Particles/CGroup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace Skylicht
4040
LifeMin(1.0f),
4141
LifeMax(2.0f),
4242
GravityValue(0.0f),
43+
UseOrientationAsBillboard(false),
4344
OrientationNormal(1.0f, 0.0f, 0.0f),
4445
OrientationUp(0.0f, 1.0f, 0.0f),
4546
Name(L"Group"),

Projects/Skylicht/Components/ParticleSystem/Particles/CGroup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ namespace Skylicht
135135
core::vector3df Gravity;
136136
core::vector3df OrientationNormal;
137137
core::vector3df OrientationUp;
138+
bool UseOrientationAsBillboard;
138139

139140
std::wstring Name;
140141
bool Visible;

0 commit comments

Comments
 (0)