1#include "Reference/WindshieldBeadMapBaseline.h"
2#include <cstring>
3#include <iostream>
4#include <stdexcept>
5
6namespace
7{
8 unsigned checks=0;
9 template<class T> void Equal(const std::vector<T>& a,const std::vector<T>& b)
10 {
11 ++checks;
12 if(a.size()!=b.size() || (!a.empty() && std::memcmp(a.data(),b.data(),a.size()*sizeof(T))))
13 throw std::runtime_error("bead/wake lookup changed");
14 }
16 {
17 WindshieldBeadMapBaseline before(surface);
18 std::vector<WindshieldRain::Surface::BeadSample> a,b;
19 std::vector<WindshieldRain::Surface::WakeSample> wa,wb;
20
21 std::vector<float> scratch(65536,-123.f),oldScratch(65536,456.f);
22 for(bool wakes:{false,true})for(bool reuse:{false,true})
23 {
24 before.BeadMap(a,wakes ? &wa : nullptr,reuse ? &oldScratch : nullptr);
25 surface.
BeadMap(b,wakes ? &wb :
nullptr,reuse ? &scratch :
nullptr);
26 Equal(a,b);if(wakes)Equal(wa,wb);
27 }
28 }
29}
31{
32 try
33 {
34
35
37 {7.608279f,1.951346f},{.6f,.4f}})
38 for(uint32_t seed:{1u,73u,9321u})
39 {
41 Compare(surface);
42 for(float x:{0.f,.5f,1.f})for(float y:{0.f,.5f,1.f})
43 {
44 surface.
Impact({size.x*x,size.y*y},.0015f,
false);
45 surface.
Impact({size.x*x,size.y*y},.0015f,
false);
46 }
47 surface.
Rebuild();Compare(surface);
48 for(unsigned i=0;i<240;++i)
49 {
52 surface.
Update(i==45 ? .25f : 1.f/30,i<180 ? 1.f : 0.f,
55 if(i%20==0)Compare(surface);
56 }
57 surface.
Clear();Compare(surface);
58 }
59 std::cout<<"PASS: "<<checks<<" exact bead/wake texture comparisons\n";
60 return 0;
61 }
62 catch(const std::exception& e){std::cerr<<"FAIL: "<<e.what()<<'\n';return 1;}
63}
void BeadMap(std::vector< BeadSample > &map, std::vector< WakeSample > *wakes=nullptr, std::vector< float > *scratchDistances=nullptr) const
void Impact(Point position, float radius, bool coalesce=true)
void WipeTriangle(Point a, Point b, Point c)
void Update(float elapsed, float rain, Point acceleration, Point wind, float airDensity, float airSpeed=-1.f, AirJet airJet={})