forked from scp-fs2open/fs2open.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticleVolume.h
More file actions
53 lines (44 loc) · 1.52 KB
/
Copy pathParticleVolume.h
File metadata and controls
53 lines (44 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include "globalincs/pstypes.h"
#include "parse/parselo.h"
#include "particle/EffectHost.h"
#include <optional>
namespace particle {
class ParticleSource;
class ParticleVolume {
public:
virtual vec3d sampleRandomPoint(const matrix &orientation, const std::tuple<const ParticleSource&, const size_t&, const vec3d&>& source, float particlesFraction, const EffectHost& host) = 0;
virtual void parse() = 0;
virtual ~ParticleVolume() = default;
std::optional<vec3d> posOffset;
std::optional<vec3d> rotOffset;
protected:
void parseCommon() {
if (optional_string("+Volume Position Offset:")) {
stuff_vec3d(&posOffset.emplace());
}
if (optional_string("+Volume Point Towards:")) {
stuff_vec3d(&rotOffset.emplace());
}
}
vec3d pointCompensateForOffsetAndRotOffset(const vec3d& point, const matrix& orientation, float posOffsetRot, float rotOffsetRot) const {
vec3d outpnt = point;
if (rotOffset.has_value()) {
vm_vec_rotate(&outpnt, &outpnt, &orientation);
vec3d rot = *rotOffset;
vm_rot_point_around_line(&rot, &rot, rotOffsetRot, &vmd_zero_vector, &vmd_z_vector);
matrix orientUse;
vm_vector_2_matrix(&orientUse, &rot);
vm_vec_unrotate(&outpnt, &outpnt, &orientUse);
vm_vec_unrotate(&outpnt, &outpnt, &orientation);
}
if (posOffset.has_value()) {
vec3d pos = *posOffset;
vm_rot_point_around_line(&pos, &pos, posOffsetRot, &vmd_zero_vector, &vmd_z_vector);
vm_vec_unrotate(&pos, &pos, &orientation);
outpnt += pos;
}
return outpnt;
}
};
}