/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/EnginePlugins/ParticlePlugin/Behavior/ParticleBehavior_Raycast.h
85 строк
3 KB
Jan Krassnigg
Added Expression Particle Behavior (#1884)
29 мар 2026, 23:32
Не верифицирован
29 мар 2026, 23:32
071fa9d
Код
Авторство
О чём код?
#pragma once #include <Foundation/Strings/String.h> #include <ParticlePlugin/Behavior/ParticleBehavior.h> class ezPhysicsWorldModuleInterface; /// How particles react when hitting a physics surface struct EZ_PARTICLEPLUGIN_DLL ezParticleRaycastHitReaction { using StorageType = ezUInt8; enum Enum { Bounce, ///< Particle bounces off the surface Die, ///< Particle is killed on impact Stop, ///< Particle stops moving Default = Bounce }; }; EZ_DECLARE_REFLECTABLE_TYPE(EZ_PARTICLEPLUGIN_DLL, ezParticleRaycastHitReaction); /// Behavior that performs physics raycasts to detect collisions /// /// Raycasts from the particle's last position to its current position. /// On collision, particles can bounce, die, or stop. /// Optionally triggers an event on collision. class EZ_PARTICLEPLUGIN_DLL ezParticleBehaviorFactory_Raycast final : public ezParticleBehaviorFactory { EZ_ADD_DYNAMIC_REFLECTION(ezParticleBehaviorFactory_Raycast, ezParticleBehaviorFactory); public: ezParticleBehaviorFactory_Raycast(); ~ezParticleBehaviorFactory_Raycast(); virtual const ezRTTI* GetBehaviorType() const override; virtual void CopyBehaviorProperties(ezParticleBehavior* pObject, bool bFirstTime) const override; virtual void QueryFinalizerDependencies(ezSet<const ezRTTI*>& inout_finalizerDeps) const override; virtual void Save(ezStreamWriter& inout_stream) const override; virtual void Load(ezStreamReader& inout_stream, const ezParticleEffectDescriptor& ownerEffectDescriptor, const ezParticleSystemDescriptor& ownerSystemDescriptor) override; ezEnum<ezParticleRaycastHitReaction> m_Reaction; ///< How particles react to collisions ezUInt8 m_uiCollisionLayer = 0; ///< Physics collision layer to raycast against ezString m_sOnCollideEvent; ///< Optional event name to raise on collision float m_fBounceFactor = 0.5f; ///< Velocity multiplier when bouncing (energy loss) float m_fSlideFactor = 0.5f; ///< How much particles slide along the surface float m_fSizeFactor = 0.1f; ///< Multiplier for particle size used in raycast length }; class EZ_PARTICLEPLUGIN_DLL ezParticleBehavior_Raycast final : public ezParticleBehavior { EZ_ADD_DYNAMIC_REFLECTION(ezParticleBehavior_Raycast, ezParticleBehavior); public: ezParticleBehavior_Raycast(); virtual void CreateRequiredStreams() override; virtual void QueryOptionalStreams() override; ezEnum<ezParticleRaycastHitReaction> m_Reaction; ezUInt8 m_uiCollisionLayer = 0; ezTempHashedString m_sOnCollideEvent; float m_fBounceFactor = 0.5f; float m_fSlideFactor = 0.5f; float m_fSizeFactor = 0.1f; protected: friend class ezParticleBehaviorFactory_Raycast; virtual void Process(ezUInt64 uiNumElements) override; void RequestRequiredWorldModulesForCache(ezParticleWorldModule* pParticleModule) override; ezPhysicsWorldModuleInterface* m_pPhysicsModule; ezProcessingStream* m_pStreamPosition = nullptr; ezProcessingStream* m_pStreamLastPosition = nullptr; ezProcessingStream* m_pStreamVelocity = nullptr; const ezProcessingStream* m_pStreamSize = nullptr; };