1
2
3#include "../Rendering/CloudRenderer11.h"
4#include "../Rendering/FrameProfiler11.h"
5#include "../Rendering/ReentryEnvelope11.h"
6#include "../Viewscreen/WeatherOverrides.h"
7#include <limits>
8#include <d3dcompiler.h>
9#include <d3d11sdklayers.h>
10#include <cmath>
11#include <cstring>
12#include <fstream>
13#include <iostream>
14#include <stdexcept>
15#include "CloudTestDiagnostics.h"
16#include "ReentryE11Fixture.h"
19using Microsoft::WRL::ComPtr;
20namespace
21{
22 constexpr UINT Width=160,Height=120;
23 unsigned checks=0;
24 void Check(bool value,const char* message) {++checks;if(!value)throw std::runtime_error(message);}
25 void HR(
HRESULT hr,
const char* message) {
if(FAILED(hr))
throw std::runtime_error(std::string(message)+
": "+std::to_string(hr));}
26 constexpr char source[]=R"(
27#if SAMPLES == 1
28Texture2D<float4> image : register(t0);
29Texture2D<float> depth : register(t1);
30#else
31Texture2DMS<float4,SAMPLES> image : register(t0);
32Texture2DMS<float,SAMPLES> depth : register(t1);
33#endif
34struct Sample {float4 color;float depth;float3 padding;};
35RWStructuredBuffer<Sample> result : register(u0);
36[numthreads(8,8,1)] void Read(uint3 id:SV_DispatchThreadID)
37{
38 if(id.x>=160 || id.y>=120)return;
39 Sample value=(Sample)0;
40#if SAMPLES == 1
41 value.color=image.Load(int3(id.xy,0));value.depth=depth.Load(int3(id.xy,0));
42#else
43 value.color=image.Load(id.xy,id.z);value.depth=depth.Load(id.xy,id.z);
44#endif
45 result[(id.y*160+id.x)*SAMPLES+id.z]=value;
46}
47float4 Fullscreen(uint vertex:SV_VertexID):SV_Position
48{return float4(vertex==2 ? 3 : -1,vertex==1 ? 3 : -1,.5,1);}
49float4 Silhouette(uint vertex:SV_VertexID):SV_Position
50{return float4(vertex==2 ? .6 : -1,vertex==1 ? -2 : .6,0,1);}
51float4 NearHull(uint vertex:SV_VertexID):SV_Position
52{float4 p=Fullscreen(vertex);p.z=.96+.01*p.x;return p;}
53float4 CityWall(uint vertex:SV_VertexID):SV_Position
54{float4 p=Fullscreen(vertex);p.z=.999+.0002*p.x;return p;}
55float4 Blue():SV_Target {return float4(.1,.2,.8,1);}
56float4 Black():SV_Target {return float4(0,0,0,1);}
57float4 NoCloud():SV_Target {discard;return 0;}
58struct ModelVertex {float4 position:SV_Position;float4 color:COLOR0;};
59ModelVertex ModelVS(float4 position:POSITION,float4 color:COLOR0)
60{ModelVertex o;o.position=position;o.color=color;return o;}
61float4 ModelPS(ModelVertex i):SV_Target{return i.color;}
62)";
63 ComPtr<ID3DBlob> Compile(const char* entry,const char* profile,UINT samples)
64 {
65 const auto count=std::to_string(samples);const D3D_SHADER_MACRO definitions[]={{"SAMPLES",count.c_str()},{nullptr,nullptr}};
66 ComPtr<ID3DBlob> code,errors;
67 const auto hr=D3DCompile(source,strlen(source),"CloudScene11.inline.hlsl",definitions,nullptr,entry,profile,
68 D3DCOMPILE_ENABLE_STRICTNESS|D3DCOMPILE_WARNINGS_ARE_ERRORS|D3DCOMPILE_OPTIMIZATION_LEVEL3,0,&code,&errors);
69 if(errors)std::cerr<<static_cast<const char*>(errors->GetBufferPointer());HR(hr,"compile scene fixture");return code;
70 }
71 struct Sample {
float color[4],depth,padding[3];};
72 struct Scene
73 {
74 ComPtr<ID3D11Texture2D> color;
75 ComPtr<ID3D11RenderTargetView>
target;
76 ComPtr<ID3D11ShaderResourceView> view;
77 SceneDepth11 depth;
78 Scene(ID3D11Device* device,UINT samples,UINT width=Width,UINT height=Height,DXGI_FORMAT format=DXGI_FORMAT_R8G8B8A8_UNORM)
79 {
80 D3D11_TEXTURE2D_DESC desc{};desc.Width=width;desc.Height=height;desc.ArraySize=desc.MipLevels=1;
81 desc.Format=format;desc.SampleDesc={samples,0};desc.BindFlags=D3D11_BIND_RENDER_TARGET|D3D11_BIND_SHADER_RESOURCE;
82 HR(device->CreateTexture2D(&desc,nullptr,&color),"scene color");HR(device->CreateRenderTargetView(color.Get(),nullptr,&target),"scene RTV");
83 HR(device->CreateShaderResourceView(color.Get(),
nullptr,&view),
"scene color SRV");HR(depth.
Create(device,width,height,desc.SampleDesc),
"scene depth");
84 }
85 void Clear(ID3D11DeviceContext* context)
86 {
87 const float black[]={0,0,0,1};context->ClearRenderTargetView(
target.Get(),black);
88 context->ClearDepthStencilView(depth.
WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
89 }
90 };
91 struct Pipeline
92 {
93 ComPtr<ID3D11VertexShader> full,silhouette,nearHull,cityWall;
94 ComPtr<ID3D11PixelShader> blue,black;
95 ComPtr<ID3D11ComputeShader>
read;
96 ComPtr<ID3D11RasterizerState> raster;
97 ComPtr<ID3D11DepthStencilState> stencil,foreground;
98 ComPtr<ID3D11VertexShader> modelVertex;
99 ComPtr<ID3D11PixelShader> modelPixel;
100 ComPtr<ID3D11InputLayout> modelLayout;
101 ComPtr<ID3D11DepthStencilState> modelDepth;
102 Pipeline(ID3D11Device* device,UINT samples)
103 {
104 auto code=Compile("Fullscreen","vs_5_0",samples);HR(device->CreateVertexShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&full),"full VS");
105 code=Compile("Silhouette","vs_5_0",samples);HR(device->CreateVertexShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&silhouette),"silhouette VS");
106 code=Compile("NearHull","vs_5_0",samples);HR(device->CreateVertexShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&nearHull),"near hull VS");
107 code=Compile("CityWall","vs_5_0",samples);HR(device->CreateVertexShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&cityWall),"city wall VS");
108 code=Compile("Blue","ps_5_0",samples);HR(device->CreatePixelShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&blue),"blue PS");
109 code=Compile("Black","ps_5_0",samples);HR(device->CreatePixelShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&black),"black PS");
110 code=Compile("Read","cs_5_0",samples);HR(device->CreateComputeShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&read),"sample CS");
111 D3D11_RASTERIZER_DESC rs{};rs.FillMode=D3D11_FILL_SOLID;rs.CullMode=D3D11_CULL_NONE;rs.DepthClipEnable=TRUE;rs.MultisampleEnable=TRUE;
112 HR(device->CreateRasterizerState(&rs,&raster),"scene rasterizer");
113 D3D11_DEPTH_STENCIL_DESC ds{};ds.StencilEnable=TRUE;ds.StencilReadMask=ds.StencilWriteMask=255;ds.DepthFunc=D3D11_COMPARISON_ALWAYS;
114 ds.FrontFace=ds.BackFace={D3D11_STENCIL_OP_KEEP,D3D11_STENCIL_OP_KEEP,D3D11_STENCIL_OP_REPLACE,D3D11_COMPARISON_ALWAYS};
115 HR(device->CreateDepthStencilState(&ds,&stencil),"stencil bands");
116 ds.StencilEnable=FALSE;ds.DepthEnable=TRUE;ds.DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ALL;
117 HR(device->CreateDepthStencilState(&ds,&foreground),"foreground depth");
118 ds.DepthFunc=D3D11_COMPARISON_LESS_EQUAL;ds.StencilEnable=TRUE;
119 HR(device->CreateDepthStencilState(&ds,&modelDepth),"model depth/stencil");
120 code=Compile("ModelVS","vs_5_0",samples);
121 HR(device->CreateVertexShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&modelVertex),"model VS");
122 const D3D11_INPUT_ELEMENT_DESC layout[]={
123 {"POSITION",0,DXGI_FORMAT_R32G32B32A32_FLOAT,0,0,D3D11_INPUT_PER_VERTEX_DATA,0},
124 {"COLOR",0,DXGI_FORMAT_R32G32B32A32_FLOAT,0,16,D3D11_INPUT_PER_VERTEX_DATA,0}};
125 HR(device->CreateInputLayout(layout,2,code->GetBufferPointer(),code->GetBufferSize(),&modelLayout),"model layout");
126 code=Compile("ModelPS","ps_5_0",samples);
127 HR(device->CreatePixelShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&modelPixel),"model PS");
128 }
129 void Model(Device11& gpu,Scene& scene,const ReentryE11Fixture::Model& model,
130 const XMFLOAT4X4& view,const XMFLOAT4X4& projection,const D3D11_VIEWPORT& viewport,bool cockpit)
131 {
132 struct Vertex {XMFLOAT4 position,color;};std::vector<Vertex> vertices;
133 for(const auto& part:model.parts)
134 {
135 if(!part.visible || part.texture<0 || part.type==5 || part.type==51 || part.type==251 || part.type==54 || part.type>=200)continue;
136 const auto matrix=XMLoadFloat4x4(&part.matWorld)*XMLoadFloat4x4(&view)*XMLoadFloat4x4(&projection);
137 const size_t stride=cockpit?32:40;
138 for(size_t i=part.startvertex;i<part.startvertex+part.primitives*3;++i)
139 {
140 Check((i+1)*stride<=model.vertices.size(),"fixture vertex bounds");
141 XMFLOAT3 position,normal;std::memcpy(&position,model.vertices.data()+i*stride,sizeof(position));
142 std::memcpy(&normal,model.vertices.data()+i*stride+12,sizeof(normal));
143 Vertex v;XMStoreFloat4(&v.position,XMVector3Transform(XMLoadFloat3(&position),matrix));
144 const float light=cockpit?.12f:.25f+.4f*std::abs(normal.z);
145 v.color={light*.65f,light*.74f,light*.85f,1};vertices.push_back(v);
146 }
147 }
148 auto* context=gpu.
Context();context->ClearState();
auto*
target=scene.target.Get();
149 context->OMSetRenderTargets(1,&target,scene.depth.WriteView());
150 context->OMSetDepthStencilState(modelDepth.Get(),cockpit?4:0);
151 context->RSSetState(raster.Get());context->RSSetViewports(1,&viewport);
152 D3D11_BUFFER_DESC bd{};bd.ByteWidth=UINT(vertices.size()*sizeof(Vertex));bd.Usage=D3D11_USAGE_IMMUTABLE;bd.BindFlags=D3D11_BIND_VERTEX_BUFFER;
153 D3D11_SUBRESOURCE_DATA data{vertices.data(),0,0};ComPtr<ID3D11Buffer> buffer;
154 HR(gpu.
Device()->CreateBuffer(&bd,&data,&buffer),
"fixture model buffer");
155 const UINT stride=sizeof(Vertex),offset=0;
156 context->IASetVertexBuffers(0,1,buffer.GetAddressOf(),&stride,&offset);
157 context->IASetInputLayout(modelLayout.Get());context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
158 context->VSSetShader(modelVertex.Get(),nullptr,0);context->PSSetShader(modelPixel.Get(),nullptr,0);
159 context->Draw(UINT(vertices.size()),0);context->OMSetRenderTargets(0,nullptr,nullptr);
160 }
161 void Hull(ID3D11DeviceContext* context,Scene& scene,const D3D11_VIEWPORT& viewport,bool city=false)
162 {
163 context->ClearState();
auto*
target=scene.target.Get();
164 context->OMSetRenderTargets(1,&target,scene.depth.WriteView());
165 context->RSSetState(raster.Get());context->RSSetViewports(1,&viewport);
166 context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
167 context->VSSetShader(city ? cityWall.Get() : nearHull.Get(),nullptr,0);context->PSSetShader(blue.Get(),nullptr,0);
168 context->OMSetDepthStencilState(foreground.Get(),0);context->Draw(3,0);
169 context->OMSetRenderTargets(0,nullptr,nullptr);
170 }
171 void Occlude(Device11& gpu,Scene& scene)
172 {
173 auto* context=gpu.
Context();
auto*
target=scene.target.Get();context->ClearState();
174 context->OMSetRenderTargets(1,&target,scene.depth.WriteView());context->RSSetState(raster.Get());
175 context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);context->VSSetShader(full.Get(),nullptr,0);context->PSSetShader(black.Get(),nullptr,0);
176
177 for(UINT band=0;band<5;++band)
178 {
179 const D3D11_VIEWPORT viewport{float(band*Width/5),0,float(Width/5),float(Height),0,1};context->RSSetViewports(1,&viewport);
180 context->OMSetDepthStencilState(stencil.Get(),band);context->Draw(3,0);
181 }
182 const D3D11_VIEWPORT viewport{0,0,float(Width),float(Height),0,1};context->RSSetViewports(1,&viewport);
183 context->OMSetDepthStencilState(foreground.Get(),0);context->VSSetShader(silhouette.Get(),nullptr,0);context->PSSetShader(blue.Get(),nullptr,0);context->Draw(3,0);
184 context->OMSetRenderTargets(0,nullptr,nullptr);
185 }
186 std::vector<Sample>
Pixels(Device11& gpu,Scene& scene,UINT samples)
187 {
189 D3D11_BUFFER_DESC desc{};desc.ByteWidth=bytes;desc.BindFlags=D3D11_BIND_UNORDERED_ACCESS;
190 desc.MiscFlags=D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;desc.StructureByteStride=
sizeof(
Sample);
191 ComPtr<ID3D11Buffer>
output,staging;HR(gpu.
Device()->CreateBuffer(&desc,
nullptr,&output),
"sample result");
192 desc.Usage=D3D11_USAGE_STAGING;desc.BindFlags=desc.MiscFlags=desc.StructureByteStride=0;desc.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
193 HR(gpu.
Device()->CreateBuffer(&desc,
nullptr,&staging),
"sample staging");ComPtr<ID3D11UnorderedAccessView> uav;
194 HR(gpu.
Device()->CreateUnorderedAccessView(
output.Get(),
nullptr,&uav),
"sample UAV");
195 ID3D11ShaderResourceView* views[]={scene.view.Get(),scene.depth.ShaderView()};auto* write=uav.Get();
196 context->CSSetShaderResources(0,2,views);context->CSSetUnorderedAccessViews(0,1,&write,
nullptr);context->CSSetShader(
read.Get(),
nullptr,0);
197 context->Dispatch(Width/8,Height/8,samples);context->ClearState();context->CopyResource(staging.Get(),
output.Get());
198 D3D11_MAPPED_SUBRESOURCE mapped{};
const HRESULT mapResult=context->Map(staging.Get(),0,D3D11_MAP_READ,0,&mapped);
199 if(FAILED(mapResult))std::cerr<<
"Device removal reason: 0x"<<std::hex<<unsigned(gpu.
RemovalReason())<<std::dec<<std::endl;
200 HR(mapResult,"sample map");
201 std::vector<Sample> pixels(Width*Height*samples);memcpy(pixels.data(),mapped.pData,bytes);context->Unmap(staging.Get(),0);return pixels;
202 }
203 };
205 {
206 ComPtr<ID3D11InfoQueue> queue;
if(FAILED(gpu.
Device()->QueryInterface(IID_PPV_ARGS(&queue))))
return;
207 for(UINT64 i=0;i<queue->GetNumStoredMessages();++i)
208 {
209 SIZE_T size=0;queue->GetMessage(i,nullptr,&size);std::vector<char> bytes(size);auto* message=reinterpret_cast<D3D11_MESSAGE*>(bytes.data());
210 HR(queue->GetMessage(i,message,&size),"debug message");if(message->Severity<=D3D11_MESSAGE_SEVERITY_WARNING)throw std::runtime_error(message->pDescription);
211 }
212 queue->ClearStoredMessages();
213 }
214
215 void TestGammaOverride()
216 {
217 float value=-1;
218 for(const auto* text:{L"0.5",L".5",L"+0.5",L" 0.5 "})
220 for(const float expected:{0.f,.001f,.25f,.999f,1.f,-1.f})
222 "GAMMA endpoints, fractions and automatic reset");
223 for(const auto* text:{L"",L" ",L"nan",L"inf",L"1.001",L"-0.5",L"-2",L"0.5junk",L"0.5 1",L"0,5",L"1e999"})
224 {
225 value=.5f;
227 }
230 for(
unsigned frame=0;frame<20;++frame)state.
Update(value,.25f,
true,1);
231 Check(std::abs(state.
strength-.5f)<.0001f,
"preview snaps to an endpoint instead of the requested fraction");
232 state.
Update(value,.1f,
false,1);
233 Check(state.
strength==0&&state.
time==0,
"fractional preview persists in simulator");
235 const float nan=std::numeric_limits<float>::quiet_NaN();
236 const Vector3 quarteringTail(-4,1,5);
239 for(float density:{3.063f,.001f,0.f}) for(float preview:{.25f,.5f,1.f})
240 {
241 const auto conditions=
Resolve(density,airflow,preview);
242 Check(conditions.strength==preview,"preview strength depends on orbital speed or density");
243 Check(
Length(conditions.windwardBody-
Vector3(0,0,-1))==0,
"preview follows quartering/tail airflow");
245 for(
unsigned frame=0;frame<8;++frame)previewState.
Update(conditions.strength,.125f,
true,1);
246 Check(previewState.
time==1.f,
"preview flow rate depends on flight speed or brightness");
247 }
248 const auto automatic=
Resolve(.001f,quarteringTail,-1);
249 Check(automatic.strength==
Strength(.001f,quarteringTail)&&
250 Length(automatic.windwardBody-quarteringTail)==0,
"GAMMA reset does not restore actual airflow");
251 Check(
Resolve(0,quarteringTail,-1).strength==0,
"automatic orbit retains preview brightness");
252 Check(
Resolve(3.063f,{0,0,0},-1).
strength==0,
"automatic hover retains preview brightness");
253 const auto off=
Resolve(.01f,{0,0,-5.7f},0);
254 state.
Update(off.strength,.1f,
true,1);
255 Check(state.
strength==0&&state.
time==0,
"GAMMA0 does not clear preview strength and phase");
256 const auto preview=
Resolve(0,quarteringTail,.5f);
257 state.
Update(preview.strength,.1f,
true,1);
258 state.
Update(preview.strength,.1f,
false,1);
259 Check(state.
strength==0&&state.
time==0,
"forced nose-first flow survives simulator entry");
260 state.
Update(
Resolve(0,quarteringTail,-1).strength,.1f,
true,1);
261 Check(state.
strength==0&&state.
time==0,
"simulator exit replays the forced preview");
262 }
263 void TestPhysicsAndState()
264 {
266 const auto rho=[](float altitude) {return 3.063f*std::exp(-altitude/7.5f);};
267 Check(
Strength(rho(0),{0,0,0})==0,
"ground/hover glow");
268 Check(
Strength(rho(5),{0,0,.25f})==0,
"atmospheric cruise glow");
269 Check(
Strength(rho(20),{0,0,2.8f})>0,
"high-speed ascent missing");
270 Check(
Strength(rho(60),{0,0,5.7f})>.8f,
"orbital entry missing");
271 Check(
Strength(rho(150),{0,0,6.f})==0,
"suborbital coast glow");
272 Check(
Strength(rho(300),{0,0,6.f})==0,
"orbit glow");
273 Check(
Strength(rho(80),{0,5,0})==
Strength(rho(80),{0,0,5}),
"belly-first entry depends on forward pitot");
274 Check(
Strength(rho(80),{-5,0,0})==
Strength(rho(80),{0,0,5}),
"sideways entry depends on forward pitot");
275 const float nan=std::numeric_limits<float>::quiet_NaN();
276 Check(
Strength(nan,{0,0,5})==0 &&
Strength(1,{nan,0,5})==0 &&
Strength(-1,{0,0,5})==0,
"invalid atmosphere glow");
279 state.
Update(1,.1f,
false,1);Check(state.
strength==0 && state.
time==0,
"simulator/ineligible entry retains state");
280 state.
Update(0,.1f,
true,1);Check(state.
strength==0 && state.
time==0,
"simulator exit replays old glow");
281 state.
Update(1,.1f,
true,1);Check(state.
strength>0,
"real re-entry fails to rearm");
282 state.
Update(0,.1f,
true,1);Check(state.
strength==0,
"vacuum/landing retains old glow");
283 state.
Update(1,.1f,
true,1);state.
Update(0,.1f,
true,2);Check(state.
strength==0 && state.
time==0,
"vehicle switch retains glow");
284 state.
Update(1,.1f,
true,2);state.
Update(1,nan,
true,2);Check(state.
strength==0,
"invalid dt retains glow");
285 for(float altitude:{0.f,5.f,40.f,60.f,80.f,100.f,150.f,300.f})
286 for(float speed:{0.f,.03f,.25f,1.f,2.f,5.7f,8.2f,15.f})
287 {
288 const float value=
Strength(rho(altitude),{speed,0,0});
289 Check(std::isfinite(value) && value>=0 && value<=1,"unbounded entry strength");
290 }
291 const std::vector<Sphere> spheres={{{0,0,0},.01f},{{.008f,0,0},.006f},{{-.008f,0,0},.006f}};
292 for(
Vector3 direction: {
Vector3(0,0,1),
Vector3(0,1,0),
Vector3(1,0,0),
Vector3(0,0,-1)})
293 {
294 const auto mesh=
Generate(spheres,direction);
295 Check(mesh.vertices.size()==2145 && mesh.indices.size()==12288,"envelope geometry size");
296 for(
const auto& vertex:mesh.vertices)Check(
Finite(vertex.position)&&
Finite(vertex.normal),
"nonfinite envelope");
297 for(auto index:mesh.indices)Check(index<mesh.vertices.size(),"invalid mesh index");
298 for(
unsigned ring=0;ring<=
Rings;++ring)
300 "sphere-support tie opens the angular seam");
301 for(
unsigned sector=1;sector<=
Segments;++sector)
302 {
303 Check(
Length(mesh.vertices[sector].position-mesh.vertices[0].position)==0,
"north cap open");
304 }
306 "wake closes into a glowing tail point");
307 const auto nose=mesh.vertices.front().position;
308 for(
const auto& s:spheres)Check(
Dot(nose,direction)>
Dot(s.center,direction)+s.radius,
"bow shock is inside hull bound");
309 }
311 Check(
Generate(spheres,{nan,0,1}).
vertices.empty(),
"invalid direction generated");
312 Check(
Generate({{{0,0,0},-1}},{0,0,1}).
vertices.empty(),
"invalid sphere generated");
313 }
314 double Energy(const std::vector<Sample>& pixels)
315 {double sum=0;for(const auto& p:pixels)sum+=p.color[0]+p.color[1]+p.color[2];return sum;}
317 {
319
320
322 unsigned hits=0;float nearest=1e30f;
323 for(
size_t i=0;i<mesh.
indices.size();i+=3)
324 {
328 const auto p=
Cross(ray,c);
const float determinant=
Dot(b,p);
329 if(std::abs(determinant)<1e-12f)continue;
330 const auto offset=eye-a;
const float u=
Dot(offset,p)/determinant;
331 const auto q=
Cross(offset,b);
const float v=
Dot(ray,q)/determinant;
332 const float t=
Dot(c,q)/determinant;
333 if(u<0||v<0||u+v>1||t<=0)continue;
334 ++hits;nearest=(std::min)(nearest,t);
335 }
336 return hits%2?nearest:0;
337 }
338 void TestAirframeAndWake()
339 {
341 const auto hull=ReentryE11Fixture::Hull(ReentryE11Fixture::Load(),ReentryE11Fixture::Cockpit());
342 const auto mesh=
Generate(hull,{0,0,-1});
343 std::cout<<
"E-11 hull radius: "<<mesh.
radius*1000<<
" m; enclosed tail camera side-ray distances:";
344 for(const auto eye:ReentryE11Fixture::TailEyes)
345 {
346 const float clearance=InteriorRayDistance(mesh,eye);
347 std::cout<<' '<<clearance*1000<<" m";
348 Check(clearance>.001f,"E-11 tail-boom camera is outside or touching the envelope");
349 }
350 std::cout<<'\n';
351 for(size_t i=0;i<hull.size();i+=97)
352 Check(InteriorRayDistance(mesh,hull[i].center)>0,"envelope intersects the visible E-11 airframe");
353 float aft=0;
for(
const auto& s:hull)aft=(std::max)(aft,
Dot(mesh.
center-s.center,mesh.
windward));
354 const auto radiusAt=[&](unsigned ring)
355 {
356 float sum=0;
357 for(
unsigned sector=0;sector<
Segments;++sector)
358 {
361 }
363 };
364 const float shoulder=radiusAt(
Rings/2);
366 {
368 if(-
Dot(p,mesh.
windward)<=aft)Check(radiusAt(ring)>=shoulder*.999f,
"wake contracts before clearing the tail");
369 }
370 Check(radiusAt(
Rings)<shoulder*.35f&&radiusAt(
Rings)>shoulder*.1f,
"wake does not converge into a finite open neck");
371
372
376 const Vector3 origin(.4f,-.3f,.2f);
auto movedHull=hull;
379 const auto moved=
Attached(movedHull,direction,worldToBody,origin);
auto expected=mesh;
Place(expected,bodyToWorld,origin);
380 for(
size_t i=0;i<mesh.
vertices.size();++i)
381 {
382 Check(
Length(moved.vertices[i].position-expected.vertices[i].position)<2e-6f,
"envelope slips under attitude change");
383 Check(
Length(moved.vertices[i].anchor-mesh.
vertices[i].anchor)<1e-4f,
"streamer roots move across the airframe");
384 Check(
Length(moved.vertices[i].materialPosition-mesh.
vertices[i].materialPosition)<1e-4f,
385 "authored flow texture slips under attitude change");
386 }
387 auto wider=hull;for(auto& s:wider)s.center.x*=1.5f;
388 const auto changed=
Generate(wider,{0,0,-1});
390 "streamer anchors ignore the hull silhouette");
391 }
392 void Save(const std::vector<Sample>& pixels,UINT samples,const std::string& name)
393 {
394 std::filesystem::create_directories("outputs/reentry-envelope");
395 std::ofstream
output(
"outputs/reentry-envelope/"+name+
".ppm",std::ios::binary);
397 for(UINT i=0;i<
Width*
Height;++i)
for(
unsigned c=0;c<3;++c)
398 {float value=0;for(UINT s=0;s<samples;++s)value+=pixels[i*samples+s].color[c]/samples;
400 Check(bool(output),"capture save");
401 }
402 void TestRender(
Device11& gpu,
const std::filesystem::path& directory,UINT samples)
403 {
406 Pipeline pipeline(gpu.
Device(),samples);Scene scene(gpu.
Device(),samples),reference(gpu.
Device(),samples);
407 XMFLOAT4X4 view,projection;XMStoreFloat4x4(&view,XMMatrixIdentity());
408 XMStoreFloat4x4(&projection,XMMatrixPerspectiveFovRH(1.f,float(Width)/Height,.001f,128));
409 const D3D11_VIEWPORT viewport{0,0,float(Width),float(Height),0,1};
410 auto mesh=
ReentryEnvelope::Generate({{{0,0,-.035f},.012f},{{.008f,0,-.038f},.006f},{{-.008f,0,-.038f},.006f}},{0,0,1});
411 const auto draw=[&](Scene&
target,
float strength=1,
float time=.5f,
float transmission=1) {
412 HR(envelope.
Render(gpu.
Context(),
target.target.Get(),
target.depth,viewport,view,projection,mesh,strength,time,transmission,42.16f),
"draw envelope");
413 };
414 scene.Clear(gpu.
Context());draw(scene);
const auto first=pipeline.Pixels(gpu,scene,samples);
415 Check(Energy(first)>10,"exterior envelope invisible");Save(first,samples,"exterior-"+std::to_string(samples));
416 double red=0,green=0,blue=0;
417 for(const auto& p:first){red+=p.color[0];green+=p.color[1];blue+=p.color[2];}
418 Check(red>green*1.6 && green>blue*2,"plasma should be predominantly red/orange");
419 double mirrorDifference=0;
420 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
421 mirrorDifference+=std::abs(first[(y*Width+x)*samples].color[0]-first[(y*Width+Width-1-x)*samples].color[0]);
422 Check(mirrorDifference>red/samples*.12,"plasma pattern is bilaterally symmetric");
423 scene.Clear(gpu.
Context());draw(scene);
const auto repeat=pipeline.Pixels(gpu,scene,samples);
424 Check(std::memcmp(first.data(),repeat.data(),first.size()*sizeof(Sample))==0,"same frame flickers");
425 scene.Clear(gpu.
Context());draw(scene,.5f);
const auto halfEnergy=Energy(pipeline.Pixels(gpu,scene,samples));
426 scene.Clear(gpu.
Context());draw(scene,.25f);
const auto quarterEnergy=Energy(pipeline.Pixels(gpu,scene,samples));
427 Check(quarterEnergy>0&&quarterEnergy<halfEnergy,"fractional strength does not change visible emission");
428 Check(halfEnergy>Energy(first)*.2&&halfEnergy<Energy(first)*.6,"half strength is not an intermediate preview");
429 scene.Clear(gpu.
Context());draw(scene,0);Check(Energy(pipeline.Pixels(gpu,scene,samples))==0,
"disabled envelope emits");
430 scene.Clear(gpu.
Context());draw(scene,1,.5f,0);Check(Energy(pipeline.Pixels(gpu,scene,samples))==0,
"opaque cloud leaks envelope");
431 scene.Clear(gpu.
Context());draw(scene,1,.5f,.25f);Check(Energy(pipeline.Pixels(gpu,scene,samples))<Energy(first)*.3,
"cloud attenuation missing");
432 scene.Clear(gpu.
Context());draw(scene,1,.9f);
const auto animated=pipeline.Pixels(gpu,scene,samples);
433 Check(std::memcmp(first.data(),animated.data(),first.size()*sizeof(Sample))!=0,"flow does not animate");
434 scene.Clear(gpu.
Context());draw(scene,1,.5f+1.f/60);
const auto nextFrame=pipeline.Pixels(gpu,scene,samples);
435 double frameDifference=0;for(size_t i=0;i<first.size();++i)
436 frameDifference+=std::abs(first[i].color[0]-nextFrame[i].color[0]);
437 std::cout<<"60 Hz flow change "<<samples<<"x: "<<frameDifference/red<<'\n';
438
439
440 Check(frameDifference>red*.3,"compression front retains slow swimming motion");
441 scene.Clear(gpu.
Context());draw(scene,1,0);
const auto loopStart=pipeline.Pixels(gpu,scene,samples);
442 scene.Clear(gpu.
Context());draw(scene,1,255.9999f);
const auto loopEnd=pipeline.Pixels(gpu,scene,samples);
443 double loopDifference=0;for(size_t i=0;i<loopStart.size();++i)for(unsigned c=0;c<3;++c)
444 loopDifference+=std::abs(loopStart[i].color[c]-loopEnd[i].color[c]);
445 std::cout<<"Flow loop boundary change "<<samples<<"x: "<<loopDifference/Energy(loopStart)<<'\n';
446 Check(loopDifference<Energy(loopStart)*.015,"flow loop pops at time wrap");
447
448
449 const auto originalMesh=mesh;
451 {{{0,0,-.035f},.012f}},{std::sqrt(1-y*y),y,0});};
452 mesh=tilted(.89999f);scene.Clear(gpu.
Context());draw(scene);
453 const auto tiltBefore=pipeline.Pixels(gpu,scene,samples);
454 mesh=tilted(.90001f);scene.Clear(gpu.
Context());draw(scene);
455 const auto tiltAfter=pipeline.Pixels(gpu,scene,samples);
456 double tiltDifference=0;for(size_t i=0;i<tiltBefore.size();++i)for(unsigned c=0;c<3;++c)
457 tiltDifference+=std::abs(tiltBefore[i].color[c]-tiltAfter[i].color[c]);
458 Check(Energy(tiltBefore)>10,"airflow continuity test has no visible plasma");
459 Check(tiltDifference<Energy(tiltBefore)*.03,"flow pops across the mesh reference axis");
460 mesh=originalMesh;
461 scene.Clear(gpu.
Context());reference.Clear(gpu.
Context());pipeline.Occlude(gpu,scene);
462 const auto before=pipeline.Pixels(gpu,scene,samples);draw(reference);draw(scene);
463 const auto expected=pipeline.Pixels(gpu,reference,samples),after=pipeline.Pixels(gpu,scene,samples);
464 unsigned visible=0;
465 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
for(UINT s=0;s<samples;++s)
466 {
467 const auto i=(y*
Width+x)*samples+s;
468 const bool blocked=before[i].depth<1 || x/(
Width/5)>=3;
469 const auto& wanted=blocked?before[i]:expected[i];
470 for(unsigned c=0;c<4;++c)Check(after[i].color[c]==wanted.color[c],"hull/cockpit occlusion or alpha damaged");
471 Check(after[i].depth==before[i].depth,"transparent envelope writes depth");
472 if(!blocked && after[i].color[0]>0)++visible;
473 }
474 Check(visible>20,"occlusion test has no exposed plasma");
475 const auto e11=ReentryE11Fixture::Load();
476 const auto cockpit=ReentryE11Fixture::Cockpit();
478 view=ReentryE11Fixture::PilotView();
479 scene.Clear(gpu.
Context());draw(scene);
const auto pilot=pipeline.Pixels(gpu,scene,samples);
480 Save(pilot,samples,"e11-pilot-"+std::to_string(samples));
481 Check(Energy(pilot)>10,"E-11 pilot is ahead of the plasma envelope");
482 const auto e11Hull=ReentryE11Fixture::Hull(e11,
cockpit);
483 float collisionNose=0,visibleNose=0;
484 for(const auto& s:ReentryE11Fixture::CollisionHull(e11))collisionNose=(std::max)(collisionNose,-s.center.z+s.radius);
485 for(const auto& s:e11Hull)visibleNose=(std::max)(visibleNose,-s.center.z);
486 Check(collisionNose<.0184556441f && visibleNose>.0184556441f,
487 "E-11 fixture no longer exercises the cockpit ahead of collision bounds");
488
489
494 std::vector<ReentryEnvelope::Sphere> pilotGlass,externalGlass;
495 for(
const auto& part:
cockpit.parts)
if(part.type==5)
496 {
498 const auto externalPart=part.matWorld*pilotView*inverseExternal;
500 }
501 Check(pilotGlass.size()==externalGlass.size() && !pilotGlass.empty(),"E-11 glass fixture missing");
502 for(size_t i=0;i<pilotGlass.size();++i)
503 Check(
ReentryEnvelope::Length(pilotGlass[i].center-externalGlass[i].center)<1e-7f,
"envelope follows selected camera instead of fixed glass mount");
504 XMFLOAT4X4 cockpitProjection;
505 XMStoreFloat4x4(&cockpitProjection,XMMatrixPerspectiveFovRH(1.f,float(Width)/Height,.000025f,.16f));
506 scene.Clear(gpu.
Context());pipeline.Model(gpu,scene,
cockpit,view,cockpitProjection,viewport,
true);
507 const auto cockpitBefore=pipeline.Pixels(gpu,scene,samples);draw(scene);
508 const auto cockpitAfter=pipeline.Pixels(gpu,scene,samples);
509 unsigned glassGlow=0,cockpitSamples=0;
510 for(size_t i=0;i<cockpitAfter.size();++i)
511 {
512 if(cockpitBefore[i].depth<1)
513 {
514 ++cockpitSamples;
515 Check(std::memcmp(&cockpitBefore[i],&cockpitAfter[i],sizeof(Sample))==0,"plasma paints E-11 cockpit geometry");
516 }
517 else if(cockpitAfter[i].color[0]>cockpitBefore[i].color[0]+.02f)++glassGlow;
518 }
519 Save(cockpitAfter,samples,"e11-windshield-"+std::to_string(samples));
520 std::cout<<"E-11 "<<samples<<"x: "<<cockpitSamples<<" protected cockpit samples; "<<glassGlow<<" windshield glow samples.\n";
521 Check(cockpitSamples>100 && glassGlow>100,"E-11 fixture lacks protected cockpit or visible windshield plasma");
522 for(const auto eye:ReentryE11Fixture::TailEyes)
523 {
524 XMStoreFloat4x4(&view,XMMatrixTranslation(-eye.x,-eye.y,-eye.z));
525 scene.Clear(gpu.
Context());pipeline.Model(gpu,scene,e11,view,projection,viewport,
false);
526 const auto tailBefore=pipeline.Pixels(gpu,scene,samples);draw(scene);
527 const auto tailAfter=pipeline.Pixels(gpu,scene,samples);
528 unsigned exposed=0;
529 for(size_t i=0;i<tailAfter.size();++i)
530 {
531 Check(tailBefore[i].depth==tailAfter[i].depth,"tail-camera plasma modifies scene depth");
532 if(tailAfter[i].color[0]>tailBefore[i].color[0]+.01f)++exposed;
533 }
534 Check(exposed>100,"tail-boom camera cannot see the enclosing plasma");
535 }
536 XMStoreFloat4x4(&view,XMMatrixIdentity());
537
539 scene.Clear(gpu.
Context());draw(scene);
const auto interior=pipeline.Pixels(gpu,scene,samples);
540 Check(Energy(interior)>10,"windshield view inside envelope invisible");Save(interior,samples,"interior-"+std::to_string(samples));
541 const auto interiorMesh=mesh;
543 scene.Clear(gpu.
Context());draw(scene);
544 Check(Energy(pipeline.Pixels(gpu,scene,samples))>10,"nearby plasma clipped by world near plane");
545
546
547
549 for(
auto& vertex:mesh.
vertices)vertex={{0,.05f,.02f},{0,0,-1},0,.2f};
550 mesh.
vertices[0].position={-.05f,-.05f,-.06f};
551 mesh.
vertices[1].position={.05f,-.05f,-.06f};
552 scene.Clear(gpu.
Context());pipeline.Hull(gpu.
Context(),scene,viewport);
553 const auto crossingBefore=pipeline.Pixels(gpu,scene,samples);draw(scene);
554 const auto crossingAfter=pipeline.Pixels(gpu,scene,samples);
555 unsigned behindHull=0,inFront=0;
556 for(UINT y=2;y<
Height-2;++y)
for(UINT x=2;x<
Width-2;++x)
557 {
558 const float rayX=(2*(x+.5f)/
Width-1)/projection._11,rayY=(1-2*(y+.5f)/Height)/projection._22;
559 const float distance=.02f/(1+.8f*rayY),hitX=rayX*distance,hitY=rayY*distance;
560 if(hitY<=-.048f || hitY>=.048f || std::abs(hitX)>=(.05f-hitY)*.5f-.002f)continue;
561 const float depthValue=(-distance*projection._33+projection._43)/distance;
562 const auto& beforeSample=crossingBefore[(y*
Width+x)*samples];
563 const auto& afterSample=crossingAfter[(y*
Width+x)*samples];
564 if(depthValue>beforeSample.depth+.002f)
565 {
566 ++behindHull;
567 for(unsigned c=0;c<4;++c)Check(beforeSample.color[c]==afterSample.color[c],"eye-crossing plasma incorrectly paints foreground hull");
568 }
569 else if(depthValue<beforeSample.depth-.002f)
570 {
571 ++inFront;
572 Check(afterSample.color[0]>beforeSample.color[0],"eye-crossing plasma incorrectly hidden by foreground depth");
573 }
574 }
575 Check(behindHull>100 && inFront>100,"near-plane fixture lacks both visible and occluded plasma");
576 mesh=interiorMesh;
577 const auto oldState=gpu.
Context();
578 oldState->RSSetViewports(1,&viewport);oldState->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
579 D3D11_SAMPLER_DESC samplerDesc{};samplerDesc.Filter=D3D11_FILTER_MIN_MAG_MIP_POINT;
580 samplerDesc.AddressU=samplerDesc.AddressV=samplerDesc.AddressW=D3D11_TEXTURE_ADDRESS_CLAMP;
581 ComPtr<ID3D11SamplerState> previousSampler;
582 HR(gpu.
Device()->CreateSamplerState(&samplerDesc,&previousSampler),
"sentinel material sampler");
583 oldState->PSSetShaderResources(0,1,reference.view.GetAddressOf());
584 oldState->PSSetSamplers(0,1,previousSampler.GetAddressOf());
585 draw(scene);D3D11_PRIMITIVE_TOPOLOGY topology{};oldState->IAGetPrimitiveTopology(&topology);
586 Check(topology==D3D11_PRIMITIVE_TOPOLOGY_LINELIST,"native pass leaked pipeline state");
587 ComPtr<ID3D11ShaderResourceView> restoredView;ComPtr<ID3D11SamplerState> restoredSampler;
588 oldState->PSGetShaderResources(0,1,&restoredView);oldState->PSGetSamplers(0,1,&restoredSampler);
589 Check(restoredView.Get()==reference.view.Get(),"authored flow texture leaked into the next pass");
590 Check(restoredSampler.Get()==previousSampler.Get(),"authored flow sampler leaked into the next pass");
591 envelope.
Reset();Check(!envelope.
Ready(),
"reset retains the authored material resources");
592 Check(envelope.
Initialize(
nullptr,directory)==E_INVALIDARG && !envelope.
Ready(),
"failed material initialization reports ready");
593 HR(envelope.
Initialize(gpu.
Device(),directory),
"device reset/reinitialize");
594 scene.Clear(gpu.
Context());draw(scene);Check(Energy(pipeline.Pixels(gpu,scene,samples))>10,
"reset loses envelope");
595 gpu.
Context()->ClearState();envelope.
Reset();DebugMessages(gpu);
596 }
597 void Preview(
Device11& gpu,
const std::filesystem::path& directory,
unsigned frames)
598 {
599 constexpr UINT width=960,height=540;
600 Scene scene(gpu.
Device(),1,width,height);Pipeline pipeline(gpu.
Device(),1);
602 const auto exterior=ReentryE11Fixture::Load(),
cockpit=ReentryE11Fixture::Cockpit();
604 const D3D11_VIEWPORT viewport{0,0,float(width),float(height),0,1};
605 D3D11_TEXTURE2D_DESC desc{};scene.color->GetDesc(&desc);
606 desc.Usage=D3D11_USAGE_STAGING;desc.BindFlags=0;desc.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
607 ComPtr<ID3D11Texture2D> staging;HR(gpu.
Device()->CreateTexture2D(&desc,
nullptr,&staging),
"preview staging");
608 std::filesystem::create_directories("outputs/reentry-envelope/preview");
609 for(unsigned camera=0;camera<4;++camera)for(unsigned frame=0;frame<frames;++frame)
610 {
611 XMFLOAT4X4 view,projection,cockpitProjection;
612 if(camera==0)view=ReentryE11Fixture::PilotView();
613 else if(camera==1)XMStoreFloat4x4(&view,XMMatrixLookAtRH(XMVectorSet(.055f,-.02f,-.04f,1),XMVectorSet(0,0,.012f,1),XMVectorSet(0,-1,0,0)));
614 else if(camera==2)XMStoreFloat4x4(&view,XMMatrixTranslation(-.0093f,.0101f,-.0289f)*XMMatrixRotationY(-.228f)*XMMatrixRotationX(-.419f));
615 else XMStoreFloat4x4(&view,XMMatrixTranslation(-.0093f,.0101f,-.0289f)*XMMatrixRotationY(XM_PI));
616 const auto rotate=camera==1?XMMatrixIdentity():XMMatrixRotationZ(XM_PI);
617 XMStoreFloat4x4(&projection,rotate*XMMatrixPerspectiveFovRH(1.f,float(width)/height,.001f,128));
618 XMStoreFloat4x4(&cockpitProjection,rotate*XMMatrixPerspectiveFovRH(1.f,float(width)/height,.000025f,.16f));
620 const float sky[]={.008f,.013f,.025f,1};gpu.
Context()->ClearRenderTargetView(scene.target.Get(),sky);
621 pipeline.Model(gpu,scene,camera==0?
cockpit:exterior,view,camera==0?cockpitProjection:projection,viewport,camera==0);
622 HR(envelope.
Render(gpu.
Context(),scene.target.Get(),scene.depth,viewport,view,projection,mesh,1,.5f+frame/30.f,1,128),
"preview draw");
623 gpu.
Context()->ClearState();gpu.
Context()->CopyResource(staging.Get(),scene.color.Get());
624 D3D11_MAPPED_SUBRESOURCE mapped{};HR(gpu.
Context()->Map(staging.Get(),0,D3D11_MAP_READ,0,&mapped),
"preview map");
625 const std::string number=frame<10?"0"+std::to_string(frame):std::to_string(frame);
626 std::ofstream
output(
"outputs/reentry-envelope/preview/e11-"+std::to_string(camera)+
"-"+number+
".ppm",std::ios::binary);
627 output<<
"P6\n"<<width<<
' '<<height<<
"\n255\n";
628 for(UINT y=0;y<height;++y)for(UINT x=0;x<width;++x)
629 output.write(
static_cast<const char*
>(mapped.pData)+y*mapped.RowPitch+x*4,3);
630 gpu.
Context()->Unmap(staging.Get(),0);Check(
bool(output),
"preview save");
631 }
632 gpu.
Context()->ClearState();DebugMessages(gpu);
633 }
634}
635int main(
int argc,
char** argv)
636{
637 InitializeCloudTestDiagnostics();
638 try
639 {
640 TestGammaOverride();TestPhysicsAndState();TestAirframeAndWake();
Device11 gpu;
641 HR(gpu.
Create({D3D_DRIVER_TYPE_WARP,true}),
"WARP debug device");
642 const auto directory=argc>1?std::filesystem::path(argv[1]):std::filesystem::
path(
"x64/Release/NativeShaders11");
643
644 if(argc>2 && std::string(argv[2])==
"--preview")
Preview(gpu,directory,36);
645 if(argc>2 && std::string(argv[2])==
"--stills")
Preview(gpu,directory,1);
646 for(UINT samples:{1u,4u})TestRender(gpu,directory,samples);
647 std::cout<<"PASS: "<<checks<<" reentry checks; CPU operating envelope/state and WARP 1x/4x exterior/interior/occlusion/reset.\n";
648 return 0;
649 }
650 catch(const std::exception& error){std::cerr<<"FAIL: "<<error.what()<<'\n';return 1;}
651}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
bool SupportsSamples(UINT count) const
ID3D11DeviceContext * Context() const
ID3D11Device * Device() const
HRESULT Create(const DeviceOptions11 &options={})
HRESULT RemovalReason() const
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport, const DirectX::XMFLOAT4X4 &view, const DirectX::XMFLOAT4X4 &projection, const ReentryEnvelope::Mesh &mesh, float strength, float time, float transmission, float visibilityKm)
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &directory={})
HRESULT Create(ID3D11Device *device, UINT width, UINT height, DXGI_SAMPLE_DESC samples)
ID3D11DepthStencilView * WriteView() const
ArrivalPreview Preview(const Input &in, const Request &r)
SRenderWeather Sample(const unsigned char *p)
Mesh Attached(std::vector< Sphere > hull, Vector3 windward, const RiseMath::Matrix &worldToBody, Vector3 origin)
constexpr unsigned Segments
Mesh Generate(const std::vector< Sphere > &spheres, Vector3 windward)
void Place(Mesh &mesh, const RiseMath::Matrix &bodyToWorld, Vector3 origin)
float Strength(float density, Vector3 airVelocity)
Vector3 Cross(Vector3 a, Vector3 b)
Conditions Resolve(float density, Vector3 airVelocity, float strengthOverride)
void AppendPart(std::vector< Sphere > &hull, const Component &part, const std::vector< uint8_t > &bytes, size_t stride, const RiseMath::Matrix &world)
float Dot(Vector3 a, Vector3 b)
constexpr uint8_t Pixels[262144]
Vector3 * Vec3TransformNormal(Vector3 *out, const Vector3 *a, const Matrix *m)
Matrix * MatrixRotationYawPitchRoll(Matrix *out, float yaw, float pitch, float roll)
Matrix * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Matrix * MatrixTranslation(Matrix *out, float x, float y, float z)
bool ParseValue(const wchar_t *text, float minimum, float maximum, float &value)
std::vector< Vertex > vertices
std::vector< Vertex > vertices
std::vector< uint16_t > indices
void Update(float target, float dt, bool allowed, uint64_t id)