Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions engine/src/resources/visualeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,25 @@ inline void movOp(float *ret, int retSize, const float *arg, int argSize) {
}

inline void addOp(float *ret, int retSize, std::array<const float *, 3> &arg, std::array<int, 3> &argSize) {
float value = arg[1][0];
for(int i = 0; i < retSize; i++) {
if(i < argSize[0] && i < argSize[1]) {
ret[i] = arg[0][i] + arg[1][i];
if(i < argSize[1]) {
value = arg[1][i];
}
if(i < argSize[0]) {
ret[i] = arg[0][i] + value;
}
}
}

inline void subOp(float *ret, int retSize, std::array<const float *, 3> &arg, std::array<int, 3> &argSize) {
float value = arg[1][0];
for(int i = 0; i < retSize; i++) {
if(i < argSize[0] && i < argSize[1]) {
ret[i] = arg[0][i] - arg[1][i];
if(i < argSize[1]) {
value = arg[1][i];
}
if(i < argSize[0]) {
ret[i] = arg[0][i] - value;
}
}
}
Expand All @@ -233,18 +241,26 @@ inline void mulOp(float *ret, int retSize, std::array<const float *, 3> &arg, st

*r = *m * *v;
} else {
float value = arg[1][0];
for(int i = 0; i < retSize; i++) {
if(i < argSize[0] && i < argSize[1]) {
ret[i] = arg[0][i] * arg[1][i];
if(i < argSize[1]) {
value = arg[1][i];
}
if(i < argSize[0]) {
ret[i] = arg[0][i] * value;
}
}
}
}

inline void divOp(float *ret, int retSize, std::array<const float *, 3> &arg, std::array<int, 3> &argSize) {
float value = arg[1][0];
for(int i = 0; i < retSize; i++) {
if(i < argSize[0] && i < argSize[1]) {
ret[i] = arg[0][i] / arg[1][i];
if(i < argSize[1]) {
value = arg[1][i];
}
if(i < argSize[0]) {
ret[i] = arg[0][i] / value;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions modules/editor/particletools/converter/effectgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ EffectGraph::EffectGraph() :

m_nodeTypes.push_back("Render/SpriteParticle");
m_nodeTypes.push_back("Render/MeshParticle");

}

void EffectGraph::scanForFunctions() {
Expand Down Expand Up @@ -70,7 +71,8 @@ void EffectGraph::scanForFunctions() {
TString name(function.attribute("name").as_string());

m_nodeTypes.push_back(name);
m_exposedModules[Url(name).baseName()] = path.toStdString();
TString baseName(Url(name).baseName());
m_exposedModules[baseName] = path.toStdString();
}
}
}
Expand Down Expand Up @@ -117,7 +119,7 @@ void EffectGraph::onNodesLoaded() {
}

StringList EffectGraph::nodeList() const {
return m_nodeTypes;
return StringList();
}

GraphNode *EffectGraph::defaultNode() const {
Expand Down
4 changes: 3 additions & 1 deletion modules/editor/particletools/converter/effectrootnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ void EffectRootNode::removeModule(EffectModule *module) {
}

void EffectRootNode::removeAllModules() {
for(auto it : getChildren()) {
Object::ObjectList children = getChildren();

for(auto it : children) {
Widget *widget = static_cast<EffectModule *>(it)->widget(nullptr);
delete widget->actor();

Expand Down
40 changes: 22 additions & 18 deletions modules/editor/particletools/converter/modules/effectmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,26 +379,30 @@ EffectModule::VariableData EffectModule::variable(const TString &name) const {
}

if(result.offset == -1 && !name.isEmpty()) {
StringList split = name.split('.');
const EffectRootNode::ParameterData *parameter = m_effect->parameterConst(split.front(), false);
if(parameter) {
result.size = EffectModule::typeSize(parameter->min.type());

TString comp;
if(split.size() > 1) {
comp = split.back();
result.size = comp.size();
}
result.min = toVector(parameter->min, comp);
result.max = toVector(parameter->max, comp);

result.space = parameter->mode;
if(result.space != Space::None) {
// Module uses invalid attribute
} else {
Variant v = EffectRootNode::toVariantHelper(name, "auto");
result.min = result.max = toVector(v);
StringList split = name.split('.');
const EffectRootNode::ParameterData *parameter = m_effect->parameterConst(split.front(), false);
if(parameter) {
result.size = EffectModule::typeSize(parameter->min.type());

TString comp;
if(split.size() > 1) {
comp = split.back();
result.size = comp.size();
}
result.min = toVector(parameter->min, comp);
result.max = toVector(parameter->max, comp);

result.size = EffectModule::typeSize(v.type());
result.space = EffectModule::Constant;
result.space = parameter->mode;
} else {
Variant v = EffectRootNode::toVariantHelper(name, "auto");
result.min = result.max = toVector(v);

result.size = EffectModule::typeSize(v.type());
result.space = EffectModule::Constant;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class EffectModule : public Object {
};

struct VariableData {
Space space = Space::_Particle;
Space space = Space::None;
int32_t offset = 0;
int32_t size = 0;

Expand Down
2 changes: 1 addition & 1 deletion modules/editor/particletools/modules/addvelocity.vfm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</params>
<attributes>
<attribute name="p.velocity" type="vec4"/>
<attributes/>
</attributes>
<operations>
<operation code="set" result="p.velocity.xyz" arg0="velocityDirection"/>
<operation code="set" result="p.velocity.w" arg0="velocitySpeed"/>
Expand Down
Loading