Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SkyPrimitiveRender.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class SkyPrimitiveRender {
7
9
10 public Camera Camera;
11
12 public void Textured_FlushWithCurrentStateAndShader(BaseTexturedBatch baseTexturedBatch, Shader shader, bool clearAfterFlush = true) {
13 int num = 0;
14 int num2 = baseTexturedBatch.TriangleIndices.Count;
15 while (num2 > 0) {
16 int num3 = MathUtils.Min(num2, 196605);
17 Display.DrawUserIndexed(
18 PrimitiveType.TriangleList,
19 shader,
21 baseTexturedBatch.TriangleVertices.Array,
22 0,
23 baseTexturedBatch.TriangleVertices.Count,
24 baseTexturedBatch.TriangleIndices.Array,
25 num,
26 num3
27 );
28 num += num3;
29 num2 -= num3;
30 }
31 if (clearAfterFlush) {
32 baseTexturedBatch.Clear();
33 }
34 }
35
36 public void Flush(PrimitivesRenderer3D primitiveRend, Matrix matrix, bool clearAfterFlush = true, int maxLayer = 2147483647) {
37 if (primitiveRend.m_sortNeeded) {
38 primitiveRend.m_sortNeeded = false;
39 primitiveRend.m_allBatches.Sort(
40 delegate(BaseBatch b1, BaseBatch b2) {
41 if (b1.Layer < b2.Layer) {
42 return -1;
43 }
44 if (b1.Layer <= b2.Layer) {
45 return 0;
46 }
47 return 1;
48 }
49 );
50 }
51 foreach (BaseBatch baseBatch in primitiveRend.m_allBatches) {
52 if (baseBatch.Layer > maxLayer) {
53 break;
54 }
55 if (!baseBatch.IsEmpty()
56 && baseBatch is TexturedBatch3D) {
57 BaseTexturedBatch baseTexturedBatch = (BaseTexturedBatch)baseBatch;
58 Display.DepthStencilState = baseTexturedBatch.DepthStencilState;
59 Display.RasterizerState = baseTexturedBatch.RasterizerState;
60 Display.BlendState = baseTexturedBatch.BlendState;
61 if (baseTexturedBatch.UseAlphaTest) {
62 ShaderAlphaTest.Texture = baseTexturedBatch.Texture;
63 ShaderAlphaTest.SamplerState = baseTexturedBatch.SamplerState;
64 ShaderAlphaTest.Transforms.World[0] = matrix;
65 ShaderAlphaTest.AlphaThreshold = 0f;
67 "SetShaderParameter",
68 modLoader => {
69 modLoader.SetShaderParameter(ShaderAlphaTest, Camera);
70 return true;
71 }
72 );
73 baseTexturedBatch.FlushWithDeviceState(ShaderAlphaTest, clearAfterFlush);
74 }
75 else {
76 Shader.Texture = baseTexturedBatch.Texture;
77 Shader.SamplerState = baseTexturedBatch.SamplerState;
78 Shader.Transforms.World[0] = matrix;
80 "SetShaderParameter",
81 modLoader => {
82 modLoader.SetShaderParameter(Shader, Camera);
83 return true;
84 }
85 );
86 baseTexturedBatch.FlushWithDeviceState(Shader, clearAfterFlush);
87 }
88 }
89 else {
90 baseBatch.Flush(matrix, Vector4.One);
91 }
92 }
93 }
94 }
95}
RasterizerState RasterizerState
void Flush(Matrix matrix, Vector4 color, bool clearAfterFlush=true)
DepthStencilState DepthStencilState
readonly DynamicArray< int > TriangleIndices
void FlushWithDeviceState(bool useAlphaTest, Texture2D texture, SamplerState samplerState, Matrix matrix, Vector4 color, bool clearAfterFlush=true)
readonly DynamicArray< VertexPositionColorTexture > TriangleVertices
static int Min(int x1, int x2)
void Flush(PrimitivesRenderer3D primitiveRend, Matrix matrix, bool clearAfterFlush=true, int maxLayer=2147483647)
void Textured_FlushWithCurrentStateAndShader(BaseTexturedBatch baseTexturedBatch, Shader shader, bool clearAfterFlush=true)
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static readonly Vector4 One