UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PerParticleAddImpulses.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
6#include "Chaos/Utilities.h"
7
8namespace Chaos
9{
11 {
12 public:
15
16 template<class T_PARTICLES>
17 inline void ApplyHelper(T_PARTICLES& InParticles, const FReal Dt, const int32 Index) const
18 {
19 InParticles.SetV(Index, InParticles.GetV(Index) + InParticles.LinearImpulseVelocity(Index));
20 }
21
22 inline void Apply(FDynamicParticles& InParticles, const FReal Dt, const int32 Index) const override //-V762
23 {
24 // @todo(mlentine): Is this something we want to support?
25 ensure(false);
26 }
27
28 inline void Apply(TRigidParticles<FReal, 3>& InParticles, const FReal Dt, const int32 Index) const override //-V762
29 {
30 if (InParticles.InvM(Index) == 0 || InParticles.Disabled(Index) || InParticles.Sleeping(Index))
31 return;
33
34 //
35 // TODO: This is the first-order approximation.
36 // If needed, we might eventually want to do a second order Euler's Equation,
37 // but if we do that we'll need to do a transform into a rotating reference frame.
38 // Just using W += InvI * (Torque - W x (I * W)) * dt is not correct, since Torque
39 // and W are in an inertial frame.
40 //
41
42 InParticles.SetW(Index, InParticles.GetW(Index) + InParticles.AngularImpulseVelocity(Index));
43 InParticles.LinearImpulseVelocity(Index) = FVec3(0);
44 InParticles.AngularImpulseVelocity(Index) = FVec3(0);
45 }
46
47 inline void Apply(TTransientPBDRigidParticleHandle<FReal, 3>& Particle, const FReal Dt) const override //-V762
48 {
49 Particle.SetV(Particle.GetV() + Particle.LinearImpulseVelocity());
50 Particle.SetW(Particle.GetW() + Particle.AngularImpulseVelocity());
51 Particle.LinearImpulseVelocity() = FVec3(0);
52 Particle.AngularImpulseVelocity() = FVec3(0);
53 }
54 };
55
56 template<class T, int d>
57 using TPerParticleAddImpulses UE_DEPRECATED(4.27, "Deprecated. this class is to be deleted, use FPerParticleAddImpulses instead") = FPerParticleAddImpulses;
58}
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition PerParticleAddImpulses.h:11
virtual ~FPerParticleAddImpulses()
Definition PerParticleAddImpulses.h:14
FPerParticleAddImpulses()
Definition PerParticleAddImpulses.h:13
void ApplyHelper(T_PARTICLES &InParticles, const FReal Dt, const int32 Index) const
Definition PerParticleAddImpulses.h:17
void Apply(TRigidParticles< FReal, 3 > &InParticles, const FReal Dt, const int32 Index) const override
Definition PerParticleAddImpulses.h:28
void Apply(TTransientPBDRigidParticleHandle< FReal, 3 > &Particle, const FReal Dt) const override
Definition PerParticleAddImpulses.h:47
void Apply(FDynamicParticles &InParticles, const FReal Dt, const int32 Index) const override
Definition PerParticleAddImpulses.h:22
Definition PerParticleRule.h:18
Definition DynamicParticles.h:11
Definition ParticleHandle.h:987
Definition RigidParticles.h:78
Definition SkeletalMeshComponent.h:307
FRealDouble FReal
Definition Real.h:22
TVector< FReal, 3 > FVec3
Definition Core.h:17
U16 Index
Definition radfft.cpp:71