diff --git a/Editor/EmitterWindow.cpp b/Editor/EmitterWindow.cpp index 3bb164344..0a3d30747 100644 --- a/Editor/EmitterWindow.cpp +++ b/Editor/EmitterWindow.cpp @@ -214,6 +214,8 @@ void EmitterWindow::SetObject(Object* obj) { object = obj; + emitterComboBox->ClearItems(); + if (object != nullptr) { for (auto& x : object->eParticleSystems) @@ -247,7 +249,6 @@ void EmitterWindow::SetObject(Object* obj) } else { - emitterComboBox->ClearItems(); memoryBudgetLabel->SetText("Memory Budget: -"); emitterWindow->SetEnabled(false); @@ -264,6 +265,11 @@ wiEmittedParticle* EmitterWindow::GetEmitter() int sel = emitterComboBox->GetSelected(); + if (sel < 0) + { + return nullptr; + } + if ((int)object->eParticleSystems.size() > sel) { return object->eParticleSystems[sel]; diff --git a/WickedEngine/wiEmittedParticle.cpp b/WickedEngine/wiEmittedParticle.cpp index 1f76b4f6a..3510861fd 100644 --- a/WickedEngine/wiEmittedParticle.cpp +++ b/WickedEngine/wiEmittedParticle.cpp @@ -97,6 +97,36 @@ wiEmittedParticle::wiEmittedParticle(const std::string& newName, const std::stri SetMaxParticleCount(10000); } +wiEmittedParticle::wiEmittedParticle(const wiEmittedParticle& other) +{ + name = other.name + "0"; + object = other.object; + materialName = other.materialName; + material = other.material; + size = other.size; + random_factor = other.random_factor; + normal_factor = other.normal_factor; + count = other.count; + life = other.life; + random_life = other.random_life; + emit = 0; + scaleX = other.scaleX; + scaleY = other.scaleY; + rotation = other.rotation; + motionBlurAmount = other.motionBlurAmount; + + + SAFE_INIT(particleBuffer); + SAFE_INIT(aliveList[0]); + SAFE_INIT(aliveList[1]); + SAFE_INIT(deadList); + SAFE_INIT(counterBuffer); + SAFE_INIT(indirectDispatchBuffer); + SAFE_INIT(indirectDrawBuffer); + SAFE_INIT(constantBuffer); + + SetMaxParticleCount(other.GetMaxParticleCount()); +} void wiEmittedParticle::SetMaxParticleCount(uint32_t value) { diff --git a/WickedEngine/wiEmittedParticle.h b/WickedEngine/wiEmittedParticle.h index 6a7a82a37..da12fe03f 100644 --- a/WickedEngine/wiEmittedParticle.h +++ b/WickedEngine/wiEmittedParticle.h @@ -5,9 +5,6 @@ #include "ShaderInterop_EmittedParticle.h" #include "wiIntersectables.h" -#include -#include - struct SkinnedVertex; struct Mesh; struct Object; @@ -20,40 +17,6 @@ class wiArchive; class wiEmittedParticle { private: - //struct Point - //{ - // XMFLOAT3 pos; - // XMFLOAT4 sizOpaMir; - // float rot; - // XMFLOAT3 vel; - // float rotVel; - // float life; - // float maxLife; - // XMFLOAT2 sizBeginEnd; - - // Point(){} - // Point(const XMFLOAT3& newPos, const XMFLOAT4& newSizOpaMir, const XMFLOAT3& newVel/*, const XMFLOAT3& newCol*/, float newLife, float newRotVel - // ,float scaleX, float scaleY) - // { - // pos=newPos; - // sizOpaMir=newSizOpaMir; - // vel=newVel; - // //col=newCol; - // life=maxLife=newLife; - // rot=newRotVel; - // rotVel=newRotVel; - // sizBeginEnd.x = sizOpaMir.x; - // sizBeginEnd.y = sizOpaMir.x*scaleX; - // } - //}; - - - //CBUFFER(ConstantBuffer, CBSLOT_OTHER_EMITTEDPARTICLE) - //{ - // float mMotionBlurAmount; - // UINT mEmitterMeshIndexCount; - // UINT mEmitCount; - //}; wiGraphicsTypes::GPUBuffer* particleBuffer; wiGraphicsTypes::GPUBuffer* aliveList[2]; @@ -85,6 +48,7 @@ public: wiEmittedParticle(); wiEmittedParticle(const std::string& newName, const std::string& newMat, Object* newObject, float newSize, float newRandomFac, float newNormalFac ,float newCount, float newLife, float newRandLife, float newScaleX, float newScaleY, float newRot); + wiEmittedParticle(const wiEmittedParticle& other); static void SetUpStatic(); static void CleanUpStatic(); diff --git a/WickedEngine/wiHairParticle.cpp b/WickedEngine/wiHairParticle.cpp index 4d1c05e77..6d20c5892 100644 --- a/WickedEngine/wiHairParticle.cpp +++ b/WickedEngine/wiHairParticle.cpp @@ -70,7 +70,30 @@ wiHairParticle::wiHairParticle(const std::string& newName, float newLen, int new Generate(); } } +wiHairParticle::wiHairParticle(const wiHairParticle& other) +{ + cb = nullptr; + particleBuffer = nullptr; + ib = nullptr; + ib_transposed = nullptr; + drawargs = nullptr; + name = other.name + "0"; + densityG = other.densityG; + lenG = other.lenG; + length = other.length; + count = other.count; + material = other.material; + object = other.object; + materialName = other.materialName; + particleCount = other.particleCount; + XMStoreFloat4x4(&OriginalMatrix_Inverse, XMMatrixInverse(nullptr, object->getMatrix())); + material = other.material; + if (material) + { + Generate(); + } +} void wiHairParticle::CleanUp() { @@ -208,7 +231,7 @@ void wiHairParticle::Settings(int l0,int l1,int l2) void wiHairParticle::Generate() { - std::vector points; + std::vector points; Mesh* mesh = object->mesh; @@ -331,7 +354,7 @@ void wiHairParticle::Generate() int ti = wiRandom::getRandom(0, 2); XMVECTOR tangent = XMVector3Normalize(XMVectorSubtract(pos[ti], pos[(ti + 1) % 3])); - Point addP; + Patch addP; ::XMStoreFloat4(&addP.posLen,vbar); XMFLOAT3 nor, tan; @@ -361,7 +384,7 @@ void wiHairParticle::Generate() GPUBufferDesc bd; ZeroMemory(&bd, sizeof(bd)); bd.Usage = USAGE_IMMUTABLE; - bd.ByteWidth = (UINT)(sizeof(Point) * particleCount); + bd.ByteWidth = (UINT)(sizeof(Patch) * particleCount); bd.BindFlags = BIND_VERTEX_BUFFER | BIND_SHADER_RESOURCE; bd.CPUAccessFlags = 0; bd.MiscFlags = RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS; diff --git a/WickedEngine/wiHairParticle.h b/WickedEngine/wiHairParticle.h index dcba1af2b..6f8ec62bb 100644 --- a/WickedEngine/wiHairParticle.h +++ b/WickedEngine/wiHairParticle.h @@ -16,7 +16,7 @@ class wiArchive; class wiHairParticle { public: - struct Point + struct Patch { XMFLOAT4 posLen; UINT normalRand; @@ -39,6 +39,13 @@ private: UINT iWidth; UINT iHeight; }; + + wiGraphicsTypes::GPUBuffer *cb; + wiGraphicsTypes::GPUBuffer *particleBuffer; + wiGraphicsTypes::GPUBuffer *ib; + wiGraphicsTypes::GPUBuffer *ib_transposed; + wiGraphicsTypes::GPUBuffer *drawargs; + static wiGraphicsTypes::VertexShader *vs; static wiGraphicsTypes::PixelShader *ps[SHADERTYPE_COUNT]; static wiGraphicsTypes::ComputeShader *cs_BITONICSORT; @@ -55,6 +62,8 @@ public: wiHairParticle(); wiHairParticle(const std::string& newName, float newLen, int newCount , const std::string& newMat, Object* newObject, const std::string& densityGroup, const std::string& lengthGroup); + wiHairParticle(const wiHairParticle& other); + void CleanUp(); void Generate(); @@ -73,12 +82,6 @@ public: Object* object; size_t particleCount; - wiGraphicsTypes::GPUBuffer *cb; - wiGraphicsTypes::GPUBuffer *particleBuffer; - wiGraphicsTypes::GPUBuffer *ib; - wiGraphicsTypes::GPUBuffer *ib_transposed; - wiGraphicsTypes::GPUBuffer *drawargs; - void Serialize(wiArchive& archive); }; diff --git a/WickedEngine/wiLoader.cpp b/WickedEngine/wiLoader.cpp index d4108d121..0422d204b 100644 --- a/WickedEngine/wiLoader.cpp +++ b/WickedEngine/wiLoader.cpp @@ -3849,8 +3849,28 @@ Object::Object(const Object& other):Streamable(other),Transform(other) physicsType = other.physicsType; transparency = other.transparency; color = other.color; + + for (auto&x : other.eParticleSystems) + { + eParticleSystems.push_back(new wiEmittedParticle(*x)); + eParticleSystems.back()->object = this; + } + for (auto&x : other.hParticleSystems) + { + hParticleSystems.push_back(new wiHairParticle(*x)); + hParticleSystems.back()->object = this; + } } -Object::~Object() { +Object::~Object() +{ + for (auto&x : eParticleSystems) + { + SAFE_DELETE(x); + } + for (auto&x : hParticleSystems) + { + SAFE_DELETE(x); + } } void Object::init() { diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 363074fab..d2af9219a 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 13; // minor bug fixes, alterations, refactors, updates - const int revision = 68; + const int revision = 69; long GetVersion() diff --git a/models/Emitter/profiling_10_30_9_49_12.csv b/models/Emitter/profiling_10_30_9_49_12.csv deleted file mode 100644 index f8a9400da..000000000 --- a/models/Emitter/profiling_10_30_9_49_12.csv +++ /dev/null @@ -1,136 +0,0 @@ -HUD frame time nsec:,16670000 - -Range Index,Elapsed Time, First Event,Last Event -0,11552,302,302 -1,26464,304,304 -2,6752,306,306 -3,13312,308,308 -4,6752,310,310 -5,8544,327,327 -6,26720,329,329 -7,13568,331,331 -8,14080,333,333 -9,10880,335,335 -10,8032,352,352 -11,23808,354,354 -12,6976,356,356 -13,15264,358,358 -14,6624,360,360 -15,21760,384,384 -16,21312,389,389 -17,21312,394,394 -18,36928,433,433 -19,47008,466,466 -20,63712,499,499 -21,394240,559,559 -22,925120,584,584 -23,10289696,609,609 -24,1822656,651,651 -25,469856,682,682 -26,565760,703,703 -27,26624,717,717 -28,26592,731,731 -29,1583776,751,751 -30,2679520,838,838 -31,5802240,853,853 -32,6654112,873,873 -33,416768,890,890 -34,641024,906,906 -35,1735904,920,920 -36,3130688,937,937 -37,3904352,953,953 -38,3941088,983,983 -39,3938144,997,997 -40,3938080,1014,1014 -41,3933120,1017,1017 -42,3933280,1034,1034 -43,3933120,1037,1037 -44,3933056,1054,1054 -45,3933152,1057,1057 -46,3936288,1071,1071 -47,3936128,1089,1089 -48,3936032,1092,1092 -49,3936064,1106,1106 -50,3935520,1124,1124 -51,3935488,1127,1127 -52,3935360,1141,1141 -53,3935264,1159,1159 -54,3935360,1162,1162 -55,3936064,1176,1176 -56,3936064,1194,1194 -57,3935136,1197,1197 -58,3934688,1211,1211 -59,3934848,1229,1229 -60,3934784,1232,1232 -61,3935456,1246,1246 -62,3935584,1264,1264 -63,3932416,1267,1267 -64,3933152,1281,1281 -65,3932384,1299,1299 -66,3932224,1302,1302 -67,3933984,1316,1316 -68,3934176,1334,1334 -69,3933056,1337,1337 -70,3932480,1351,1351 -71,3932480,1369,1369 -72,3932544,1372,1372 -73,3933664,1386,1386 -74,3933760,1404,1404 -75,3933536,1407,1407 -76,3934432,1421,1421 -77,3934496,1439,1439 -78,3932864,1442,1442 -79,3937216,1456,1456 -80,3937248,1474,1474 -81,3936160,1477,1477 -82,3936160,1491,1491 -83,3936096,1509,1509 -84,3935936,1512,1512 -85,3935872,1526,1526 -86,3935264,1543,1543 -87,3935168,1546,1546 -88,3935072,1560,1560 -89,3935072,1577,1577 -90,3935008,1580,1580 -91,3935008,1594,1594 -92,3934976,1611,1611 -93,3934464,1614,1614 -94,3934432,1628,1628 -95,3934432,1642,1642 -96,3934208,1659,1659 -97,3934176,1662,1662 -98,3934144,1676,1676 -99,3934112,1694,1694 -100,3932416,1697,1697 -101,3934080,1711,1711 -102,3934240,1729,1729 -103,3934272,1732,1732 -104,3935328,1746,1746 -105,3935392,1764,1764 -106,3935072,1767,1767 -107,3933696,1781,1781 -108,3933792,1799,1799 -109,3933792,1802,1802 -110,3934816,1816,1816 -111,3951552,1834,1834 -112,3951008,1837,1837 -113,3951840,1851,1851 -114,3951968,1869,1869 -115,3952000,1872,1872 -116,3952480,1886,1886 -117,3951104,1904,1904 -118,3950304,1907,1907 -119,3950464,1921,1921 -120,3950336,1939,1939 -121,3950304,1942,1942 -122,3950624,1956,1956 -123,3950592,1974,1974 -124,3950560,1977,1977 -125,5083744,1996,1996 -126,6175968,2009,2009 -127,6180064,2023,2023 -128,6183200,2037,2037 -129,6182624,2054,2054 -130,6182848,2057,2057 -131,6188480,2074,2074 -132,6199360,2077,2077 diff --git a/models/Emitter/temp/history0 b/models/Emitter/temp/history0 deleted file mode 100644 index 07e8b4f08..000000000 Binary files a/models/Emitter/temp/history0 and /dev/null differ diff --git a/models/Emitter/temp/history1 b/models/Emitter/temp/history1 deleted file mode 100644 index 210bf1eee..000000000 Binary files a/models/Emitter/temp/history1 and /dev/null differ diff --git a/models/Emitter/temp/history2 b/models/Emitter/temp/history2 deleted file mode 100644 index cfaed3adf..000000000 Binary files a/models/Emitter/temp/history2 and /dev/null differ