| 38 | } |
| 39 | |
| 40 | bool ParticleEmitterGraphCPU::Load(ReadStream* stream, bool loadMeta) |
| 41 | { |
| 42 | if (Base::Load(stream, loadMeta)) |
| 43 | return true; |
| 44 | |
| 45 | // Assign the offset in the sorted indices buffer to the rendering modules |
| 46 | uint32 lastSortModuleSortedIndicesOffset = 0xFFFFFFFF; |
| 47 | uint32 sortedIndicesOffset = 0; |
| 48 | for (int32 i = 0; i < RenderModules.Count(); i++) |
| 49 | { |
| 50 | const auto module = RenderModules[i]; |
| 51 | module->SortedIndicesOffset = lastSortModuleSortedIndicesOffset; |
| 52 | |
| 53 | if (module->TypeID == 402 && (ParticleSortMode)module->Values[2].AsInt != ParticleSortMode::None) |
| 54 | { |
| 55 | // Allocate sorted indices buffer space for sorting modules |
| 56 | lastSortModuleSortedIndicesOffset = sortedIndicesOffset; |
| 57 | module->SortedIndicesOffset = sortedIndicesOffset; |
| 58 | sortedIndicesOffset += Capacity * sizeof(int32); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Assign ribbon modules offset in the sorted ribbon particles indices buffer |
| 63 | int32 ribbonOrderOffset = 0; |
| 64 | for (int32 i = 0; i < RibbonRenderingModules.Count(); i++) |
| 65 | { |
| 66 | const auto module = RibbonRenderingModules[i]; |
| 67 | module->RibbonOrderOffset = ribbonOrderOffset; |
| 68 | ribbonOrderOffset += Capacity; |
| 69 | } |
| 70 | |
| 71 | // Initialize default particle data |
| 72 | _defaultParticleData.Resize(Layout.Size); |
| 73 | for (int32 i = 0; i < Layout.Attributes.Count(); i++) |
| 74 | { |
| 75 | const auto& attr = Layout.Attributes[i]; |
| 76 | switch (attr.ValueType) |
| 77 | { |
| 78 | #define SETUP_ATTR(type, valueType, getter) \ |
| 79 | case ParticleAttribute::ValueTypes::valueType: \ |
| 80 | *(type*)(_defaultParticleData.Get() + attr.Offset) = AttributesDefaults[i].getter; \ |
| 81 | break |
| 82 | SETUP_ATTR(float, Float, AsFloat); |
| 83 | SETUP_ATTR(Float2, Float2, AsFloat2()); |
| 84 | SETUP_ATTR(Float3, Float3, AsFloat3()); |
| 85 | SETUP_ATTR(Float4, Float4, AsFloat4()); |
| 86 | SETUP_ATTR(int32, Int, AsInt); |
| 87 | SETUP_ATTR(uint32, Uint, AsUint); |
| 88 | #undef SETUP_ATTR |
| 89 | default: ; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | void ParticleEmitterGraphCPU::InitializeNode(Node* node) |
| 97 | { |