Line | |
---|
1 | #ifndef _Mutation_H__
|
---|
2 | #define _Mutation_H__
|
---|
3 |
|
---|
4 | #include <vector>
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 | #include "common.h"
|
---|
8 | #include "Halton.h"
|
---|
9 |
|
---|
10 | namespace GtpVisibilityPreprocessor {
|
---|
11 |
|
---|
12 | class Vector2;
|
---|
13 | class Vector3;
|
---|
14 | class VssRay;
|
---|
15 | class Preprocessor;
|
---|
16 | struct SimpleRay;
|
---|
17 | class SimpleRayContainer;
|
---|
18 |
|
---|
19 | struct VssRayContainer;
|
---|
20 |
|
---|
21 | class MutationBasedDistribution: public SamplingStrategy
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | MutationBasedDistribution(Preprocessor &preprocessor);
|
---|
25 | virtual void Update(VssRayContainer &vssRays);
|
---|
26 |
|
---|
27 | virtual bool RequiresRays() { return true; }
|
---|
28 |
|
---|
29 | private:
|
---|
30 | virtual bool GenerateSample(SimpleRay &ray);
|
---|
31 |
|
---|
32 | bool
|
---|
33 | GenerateMutation(const int index, SimpleRay &ray);
|
---|
34 | bool
|
---|
35 | GenerateSilhouetteMutation(const int index, SimpleRay &ray);
|
---|
36 |
|
---|
37 | bool
|
---|
38 | GenerateMutationCandidate(const int index,
|
---|
39 | SimpleRay &ray,
|
---|
40 | Intersectable *object,
|
---|
41 | const AxisAlignedBox3 &box
|
---|
42 | );
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 | struct RayEntry {
|
---|
47 | // halton sequence for generatin gmutations of this ray
|
---|
48 | VssRay *mRay;
|
---|
49 | int mMutations;
|
---|
50 | int mUnsuccessfulMutations;
|
---|
51 | HaltonSequence mHalton;
|
---|
52 | float mImportance;
|
---|
53 | float mCdf;
|
---|
54 |
|
---|
55 | float GetSamplingFactor() const { return mMutations/mImportance; }
|
---|
56 | RayEntry() {}
|
---|
57 | RayEntry(VssRay *r):mRay(r),
|
---|
58 | mMutations(0),
|
---|
59 | mUnsuccessfulMutations(0),
|
---|
60 | mHalton(),
|
---|
61 | mImportance(1.0f) {}
|
---|
62 | };
|
---|
63 |
|
---|
64 |
|
---|
65 | Vector3
|
---|
66 | ComputeOriginMutation(const VssRay &ray,
|
---|
67 | const Vector3 &U,
|
---|
68 | const Vector3 &V,
|
---|
69 | const Vector2 vr2,
|
---|
70 | const float radius
|
---|
71 | );
|
---|
72 |
|
---|
73 | Vector3
|
---|
74 | ComputeTerminationMutation(const VssRay &ray,
|
---|
75 | const Vector3 &U,
|
---|
76 | const Vector3 &V,
|
---|
77 | const Vector2 vr2,
|
---|
78 | const float radius
|
---|
79 | );
|
---|
80 |
|
---|
81 | RayEntry &GetEntry(const int index) {
|
---|
82 | return mRays[(mBufferStart+index)%mRays.size()];
|
---|
83 | }
|
---|
84 |
|
---|
85 | vector<RayEntry> mRays;
|
---|
86 | int mMaxRays;
|
---|
87 | float mOriginMutationSize;
|
---|
88 | int mBufferStart;
|
---|
89 | int mLastIndex;
|
---|
90 | };
|
---|
91 |
|
---|
92 |
|
---|
93 | }
|
---|
94 |
|
---|
95 | #endif
|
---|
96 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.