Debian Codegraph @

demo/ChipmunkDebugDraw.c

raw symbols SCIP
1 /* Copyright (c) 2007 Scott Lembcke
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 * SOFTWARE.
20 */
21
22 #include <limits.h>
23 #include <stddef.h>
24 #include <string.h>
25
26 #include "sokol/sokol_gfx.h"cxx . . $ `<file>/demo/sokol/sokol_gfx.h`/
27
28 #include "chipmunk/chipmunk_private.h"cxx . . $ `<file>/include/chipmunk/chipmunk_private.h`/
29 #include "ChipmunkDebugDraw.h"cxx . . $ `<file>/demo/ChipmunkDebugDraw.h`/
30
31 cpTransformcxx . . $ cpTransform# ChipmunkDebugDrawVPMatrixcxx . . $ ChipmunkDebugDrawVPMatrix.;
32 float ChipmunkDebugDrawPointLineScalecxx . . $ ChipmunkDebugDrawPointLineScale. = 1.0f;
33
34 #define GLSL33cxx . . $ `demo/ChipmunkDebugDraw.c:34:9`!(x) "#version 330\n" #x
35
36 static sg_bindingscxx . . $ sg_bindings# bindingscxx . . $ bindings.;
37 static sg_pipelinecxx . . $ sg_pipeline# pipelinecxx . . $ pipeline.;
38
39 typedef structcxx . . $ $anonymous_type_5d61c4eaa9701b55_0# {float xcxx . . $ $anonymous_type_5d61c4eaa9701b55_0#x., ycxx . . $ $anonymous_type_5d61c4eaa9701b55_0#y.;} float2cxx . . $ float2#;
40 typedef structcxx . . $ $anonymous_type_5d61c4eaa9701b55_1# {uint8_tcxx . . $ uint8_t# rcxx . . $ $anonymous_type_5d61c4eaa9701b55_1#r., gcxx . . $ $anonymous_type_5d61c4eaa9701b55_1#g., bcxx . . $ $anonymous_type_5d61c4eaa9701b55_1#b., acxx . . $ $anonymous_type_5d61c4eaa9701b55_1#a.;} RGBA8cxx . . $ RGBA8#;
41 typedef structcxx . . $ $anonymous_type_5d61c4eaa9701b55_2# {float2cxx . . $ float2# poscxx . . $ $anonymous_type_5d61c4eaa9701b55_2#pos.; float2cxx . . $ float2# uvcxx . . $ $anonymous_type_5d61c4eaa9701b55_2#uv.; float rcxx . . $ $anonymous_type_5d61c4eaa9701b55_2#r.; RGBA8cxx . . $ RGBA8# fillcxx . . $ $anonymous_type_5d61c4eaa9701b55_2#fill., outlinecxx . . $ $anonymous_type_5d61c4eaa9701b55_2#outline.;} Vertexcxx . . $ Vertex#;
42 typedef uint16_tcxx . . $ uint16_t# Indexcxx . . $ Index#;
43
44 static RGBA8cxx . . $ RGBA8# cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# c){return (RGBA8cxx . . $ RGBA8#){(uint8_tcxx . . $ uint8_t#)(0xFF*c.rcxx . . $ cpSpaceDebugColor#r.), (uint8_tcxx . . $ uint8_t#)(0xFF*c.gcxx . . $ cpSpaceDebugColor#g.), (uint8_tcxx . . $ uint8_t#)(0xFF*c.bcxx . . $ cpSpaceDebugColor#b.), (uint8_tcxx . . $ uint8_t#)(0xFF*c.acxx . . $ cpSpaceDebugColor#a.)};}
45
46 typedef structcxx . . $ $anonymous_type_5d61c4eaa9701b55_3# {
47 float U_vp_matrixcxx . . $ $anonymous_type_5d61c4eaa9701b55_3#U_vp_matrix.[16];
48 } Uniformscxx . . $ Uniforms#;
49
50 // Meh, just max out 16 bit index size.
51 #define VERTEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:51:9`! (64*1024)
52 #define INDEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:52:9`! (128*1024)
53
54 static sg_buffercxx . . $ sg_buffer# VertexBuffercxx . . $ VertexBuffer., IndexBuffercxx . . $ IndexBuffer.;
55 static size_t VertexCountcxx . . $ VertexCount., IndexCountcxx . . $ IndexCount.;
56
57 static Vertexcxx . . $ Vertex# Vertexescxx . . $ Vertexes.[VERTEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:51:9`!];
58 static uint16_tcxx . . $ uint16_t# Indexescxx . . $ Indexes.[INDEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:52:9`!];
59
60 void
61 ChipmunkDebugDrawInitcxx . . $ ChipmunkDebugDrawInit(49f6e7a06ebc5aa8).(void)
62 {
63 VertexBuffercxx . . $ VertexBuffer. = sg_make_buffercxx . . $ sg_make_buffer(5efb77b03fd1b393).(&(sg_buffer_desccxx . . $ sg_buffer_desc#){
64 .label = "ChipmunkDebugDraw Vertex Buffer",
65 .size = VERTEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:51:9`!*sizeof(Vertexcxx . . $ Vertex#),
66 .type = SG_BUFFERTYPE_VERTEXBUFFERcxx . . $ SG_BUFFERTYPE_VERTEXBUFFER.,
67 .usage = SG_USAGE_STREAMcxx . . $ SG_USAGE_STREAM.,
68 });
69
70 IndexBuffercxx . . $ IndexBuffer. = sg_make_buffercxx . . $ sg_make_buffer(5efb77b03fd1b393).(&(sg_buffer_desccxx . . $ sg_buffer_desc#){
71 .label = "ChipmunkDebugDraw Index Buffer",
72 .size = INDEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:52:9`!*sizeof(Indexcxx . . $ Index#),
73 .type = SG_BUFFERTYPE_INDEXBUFFERcxx . . $ SG_BUFFERTYPE_INDEXBUFFER.,
74 .usage = SG_USAGE_STREAMcxx . . $ SG_USAGE_STREAM.,
75 });
76
77 bindingscxx . . $ bindings. = (sg_bindingscxx . . $ sg_bindings#){
78 .vertex_buffers[0] = VertexBuffercxx . . $ VertexBuffer.,
79 .index_buffer = IndexBuffercxx . . $ IndexBuffer.,
80 };
81
82 sg_shadercxx . . $ sg_shader# shd = sg_make_shadercxx . . $ sg_make_shader(ab0d6bdcaa5aceeb).(&(sg_shader_desccxx . . $ sg_shader_desc#){
83 .vs.uniform_blocks[0] = {
84 .size = sizeof(Uniformscxx . . $ Uniforms#),
85 .uniforms[0] = {.name = "U_vp_matrix", .type = SG_UNIFORMTYPE_MAT4cxx . . $ SG_UNIFORMTYPE_MAT4.},
86 },
87 .vs.source = GLSL33cxx . . $ `demo/ChipmunkDebugDraw.c:34:9`!(
88 layout(location = 0) in vec2 IN_pos;
89 layout(location = 1) in vec2 IN_uv;
90 layout(location = 2) in float IN_radius;
91 layout(location = 3) in vec4 IN_fill;
92 layout(location = 4) in vec4 IN_outline;
93
94 uniform mat4 U_vp_matrix;
95
96 out struct {
97 vec2 uv;
98 vec4 fill;
99 vec4 outline;
100 } FRAG;
101
102 void main(){
103 gl_Position = U_vp_matrix*vec4(IN_pos + IN_radius*IN_uv, 0, 1);
104 FRAG.uv = IN_uv;
105 FRAG.fill = IN_fill;
106 FRAG.fill.rgb *= IN_fill.a;
107 FRAG.outline = IN_outline;
108 FRAG.outline.a *= IN_outline.a;
109 }
110 ),
111 .fs.source = GLSL33cxx . . $ `demo/ChipmunkDebugDraw.c:34:9`!(
112 in struct {
113 vec2 uv;
114 vec4 fill;
115 vec4 outline;
116 } FRAG;
117
118 out vec4 OUT_color;
119
120 void main(){
121 float len = length(FRAG.uv);
122 float fw = length(fwidth(FRAG.uv));
123 float mask = smoothstep(-1, fw - 1, -len);
124
125 float outline = 1 - fw;
126 float outline_mask = smoothstep(outline - fw, outline, len);
127 vec4 color = FRAG.fill + (FRAG.outline - FRAG.fill*FRAG.outline.a)*outline_mask;
128 OUT_color = color*mask;
129 }
130 ),
131 });
132
133 pipelinecxx . . $ pipeline. = sg_make_pipelinecxx . . $ sg_make_pipeline(6e5e446a35687b83).(&(sg_pipeline_desccxx . . $ sg_pipeline_desc#){
134 .shader = shd,
135 .blend = {
136 .enabled = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!,
137 .src_factor_rgb = SG_BLENDFACTOR_ONEcxx . . $ SG_BLENDFACTOR_ONE.,
138 .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHAcxx . . $ SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA.
139 },
140 .index_type = SG_INDEXTYPE_UINT16cxx . . $ SG_INDEXTYPE_UINT16.,
141 .layout = {
142 .attrs = {
143 [0] = {.offset = offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:431:9`!(Vertex, pos), .format = SG_VERTEXFORMAT_FLOAT2cxx . . $ SG_VERTEXFORMAT_FLOAT2.},
144 [1] = {.offset = offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:431:9`!(Vertex, uv), .format = SG_VERTEXFORMAT_FLOAT2cxx . . $ SG_VERTEXFORMAT_FLOAT2.},
145 [2] = {.offset = offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:431:9`!(Vertex, r), .format = SG_VERTEXFORMAT_FLOATcxx . . $ SG_VERTEXFORMAT_FLOAT.},
146 [3] = {.offset = offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:431:9`!(Vertex, fill), .format = SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.},
147 [4] = {.offset = offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:431:9`!(Vertex, outline), .format = SG_VERTEXFORMAT_UBYTE4Ncxx . . $ SG_VERTEXFORMAT_UBYTE4N.},
148 }
149 }
150 });
151 }
152
153 static Vertexcxx . . $ Vertex# *push_vertexescxx . . $ push_vertexes(19a9b1b0b1bd3c57).(size_t vcount, const Indexcxx . . $ Index# *index_src, size_t icount){
154 cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(VertexCount + vcount <= VERTEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:51:9`! || IndexCount + icount <= INDEX_MAXcxx . . $ `demo/ChipmunkDebugDraw.c:52:9`!, "Geometry buffer full.");
155
156 Vertexcxx . . $ Vertex# *vertex_dst = Vertexescxx . . $ Vertexes. + VertexCountcxx . . $ VertexCount.;
157 size_t base = VertexCountcxx . . $ VertexCount.;
158 VertexCountcxx . . $ VertexCount. += vcount;
159
160 Indexcxx . . $ Index# *index_dst = Indexescxx . . $ Indexes. + IndexCountcxx . . $ IndexCount.;
161 for(size_t i = 0; i < icount; i++) index_dst[i] = index_src[i] + (Indexcxx . . $ Index#)base;
162 IndexCountcxx . . $ IndexCount. += icount;
163
164 return vertex_dst;
165 }
166
167 void ChipmunkDebugDrawDotcxx . . $ ChipmunkDebugDrawDot(227e9b49eafe2913).(cpFloatcxx . . $ cpFloat# size, cpVectcxx . . $ cpVect# pos, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# fillColor)
168 {
169 float r = (float)(size*0.5f*ChipmunkDebugDrawPointLineScalecxx . . $ ChipmunkDebugDrawPointLineScale.);
170 RGBA8cxx . . $ RGBA8# fill = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(fillColor);
171 Vertexcxx . . $ Vertex# *vertexes = push_vertexescxx . . $ push_vertexes(19a9b1b0b1bd3c57).(4, (Indexcxx . . $ Index#[]){0, 1, 2, 0, 2, 3}, 6);
172 vertexes[0] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, {-1, -1}, r, fill, fill};
173 vertexes[1] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, {-1, 1}, r, fill, fill};
174 vertexes[2] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, { 1, 1}, r, fill, fill};
175 vertexes[3] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, { 1, -1}, r, fill, fill};
176 }
177
178 void ChipmunkDebugDrawCirclecxx . . $ ChipmunkDebugDrawCircle(14e7ba4e04136dff).(cpVectcxx . . $ cpVect# pos, cpFloatcxx . . $ cpFloat# angle, cpFloatcxx . . $ cpFloat# radius, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# outlineColor, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# fillColor)
179 {
180 float r = (float)radius + ChipmunkDebugDrawPointLineScalecxx . . $ ChipmunkDebugDrawPointLineScale.;
181 RGBA8cxx . . $ RGBA8# fill = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(fillColor), outline = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(outlineColor);
182 Vertexcxx . . $ Vertex# *vertexes = push_vertexescxx . . $ push_vertexes(19a9b1b0b1bd3c57).(4, (Indexcxx . . $ Index#[]){0, 1, 2, 0, 2, 3}, 6);
183 vertexes[0] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, {-1, -1}, r, fill, outline};
184 vertexes[1] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, {-1, 1}, r, fill, outline};
185 vertexes[2] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, { 1, 1}, r, fill, outline};
186 vertexes[3] = (Vertexcxx . . $ Vertex#){{(float)pos.xcxx . . $ cpVect#x., (float)pos.ycxx . . $ cpVect#y.}, { 1, -1}, r, fill, outline};
187
188 ChipmunkDebugDrawSegmentcxx . . $ ChipmunkDebugDrawSegment(307cf2b0f0a496c2).(pos, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(pos, cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(cpvforanglecxx . . $ cpvforangle(8d5769cc69967cd4).(angle), 0.75f*radius)), outlineColor);
189 }
190
191 void ChipmunkDebugDrawSegmentcxx . . $ ChipmunkDebugDrawSegment(307cf2b0f0a496c2).(cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# color)
192 {
193 ChipmunkDebugDrawFatSegmentcxx . . $ ChipmunkDebugDrawFatSegment(972494e4e0a31225).(a, b, 0.0f, color, color);
194 }
195
196 void ChipmunkDebugDrawFatSegmentcxx . . $ ChipmunkDebugDrawFatSegment(972494e4e0a31225).(cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# radius, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# outlineColor, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# fillColor)
197 {
198 static const Indexcxx . . $ Index# indexes[] = {0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7};
199 Vertexcxx . . $ Vertex# *vertexes = push_vertexescxx . . $ push_vertexes(19a9b1b0b1bd3c57).(8, indexes, 18);
200
201 cpVectcxx . . $ cpVect# t = cpvnormalizecxx . . $ cpvnormalize(e06142a62109ae08).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(b, a));
202
203 float r = (float)radius + ChipmunkDebugDrawPointLineScalecxx . . $ ChipmunkDebugDrawPointLineScale.;
204 RGBA8cxx . . $ RGBA8# fill = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(fillColor), outline = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(outlineColor);
205
206 vertexes[0] = (Vertexcxx . . $ Vertex#){{(float)a.xcxx . . $ cpVect#x., (float)a.ycxx . . $ cpVect#y.}, {(float)(-t.xcxx . . $ cpVect#x. + t.ycxx . . $ cpVect#y.), (float)(-t.xcxx . . $ cpVect#x. - t.ycxx . . $ cpVect#y.)}, r, fill, outline};
207 vertexes[1] = (Vertexcxx . . $ Vertex#){{(float)a.xcxx . . $ cpVect#x., (float)a.ycxx . . $ cpVect#y.}, {(float)(-t.xcxx . . $ cpVect#x. - t.ycxx . . $ cpVect#y.), (float)(+t.xcxx . . $ cpVect#x. - t.ycxx . . $ cpVect#y.)}, r, fill, outline};
208 vertexes[2] = (Vertexcxx . . $ Vertex#){{(float)a.xcxx . . $ cpVect#x., (float)a.ycxx . . $ cpVect#y.}, {(float)(-0.0 + t.ycxx . . $ cpVect#y.), (float)(-t.xcxx . . $ cpVect#x. + 0.0)}, r, fill, outline};
209 vertexes[3] = (Vertexcxx . . $ Vertex#){{(float)a.xcxx . . $ cpVect#x., (float)a.ycxx . . $ cpVect#y.}, {(float)(-0.0 - t.ycxx . . $ cpVect#y.), (float)(+t.xcxx . . $ cpVect#x. + 0.0)}, r, fill, outline};
210 vertexes[4] = (Vertexcxx . . $ Vertex#){{(float)b.xcxx . . $ cpVect#x., (float)b.ycxx . . $ cpVect#y.}, {(float)(+0.0 + t.ycxx . . $ cpVect#y.), (float)(-t.xcxx . . $ cpVect#x. - 0.0)}, r, fill, outline};
211 vertexes[5] = (Vertexcxx . . $ Vertex#){{(float)b.xcxx . . $ cpVect#x., (float)b.ycxx . . $ cpVect#y.}, {(float)(+0.0 - t.ycxx . . $ cpVect#y.), (float)(+t.xcxx . . $ cpVect#x. - 0.0)}, r, fill, outline};
212 vertexes[6] = (Vertexcxx . . $ Vertex#){{(float)b.xcxx . . $ cpVect#x., (float)b.ycxx . . $ cpVect#y.}, {(float)(+t.xcxx . . $ cpVect#x. + t.ycxx . . $ cpVect#y.), (float)(-t.xcxx . . $ cpVect#x. + t.ycxx . . $ cpVect#y.)}, r, fill, outline};
213 vertexes[7] = (Vertexcxx . . $ Vertex#){{(float)b.xcxx . . $ cpVect#x., (float)b.ycxx . . $ cpVect#y.}, {(float)(+t.xcxx . . $ cpVect#x. - t.ycxx . . $ cpVect#y.), (float)(+t.xcxx . . $ cpVect#x. + t.ycxx . . $ cpVect#y.)}, r, fill, outline};
214 }
215
216 #define MAX_POLY_VERTEXEScxx . . $ `demo/ChipmunkDebugDraw.c:216:9`! 64
217 // Fill needs (count - 2) triangles.
218 // Outline needs 4*count triangles.
219 #define MAX_POLY_INDEXEScxx . . $ `demo/ChipmunkDebugDraw.c:219:9`! (3*(5*MAX_POLY_VERTEXEScxx . . $ `demo/ChipmunkDebugDraw.c:216:9`! - 2))
220
221 void ChipmunkDebugDrawPolygoncxx . . $ ChipmunkDebugDrawPolygon(6db671fc658f3d5c).(int count, const cpVectcxx . . $ cpVect# *verts, cpFloatcxx . . $ cpFloat# radius, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# outlineColor, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# fillColor)
222 {
223 RGBA8cxx . . $ RGBA8# fill = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(fillColor), outline = cp_to_rgbacxx . . $ cp_to_rgba(5c3acd0bccfd774f).(outlineColor);
224
225 Indexcxx . . $ Index# indexes[MAX_POLY_INDEXEScxx . . $ `demo/ChipmunkDebugDraw.c:219:9`!];
226
227 // Polygon fill triangles.
228 for(int i = 0; i < count - 2; i++){
229 indexes[3*i + 0] = 0;
230 indexes[3*i + 1] = 4*(i + 1);
231 indexes[3*i + 2] = 4*(i + 2);
232 }
233
234 // Polygon outline triangles.
235 Indexcxx . . $ Index# *cursor = indexes + 3*(count - 2);
236 for(int i0 = 0; i0 < count; i0++){
237 int i1 = (i0 + 1)%count;
238 cursor[12*i0 + 0] = 4*i0 + 0;
239 cursor[12*i0 + 1] = 4*i0 + 1;
240 cursor[12*i0 + 2] = 4*i0 + 2;
241 cursor[12*i0 + 3] = 4*i0 + 0;
242 cursor[12*i0 + 4] = 4*i0 + 2;
243 cursor[12*i0 + 5] = 4*i0 + 3;
244 cursor[12*i0 + 6] = 4*i0 + 0;
245 cursor[12*i0 + 7] = 4*i0 + 3;
246 cursor[12*i0 + 8] = 4*i1 + 0;
247 cursor[12*i0 + 9] = 4*i0 + 3;
248 cursor[12*i0 + 10] = 4*i1 + 0;
249 cursor[12*i0 + 11] = 4*i1 + 1;
250 }
251
252 float inset = (float)-cpfmaxcxx . . $ cpfmax(d8e7e0733fa41c87).(0, 2*ChipmunkDebugDrawPointLineScalecxx . . $ ChipmunkDebugDrawPointLineScale. - radius);
253 float outset = (float)radius + ChipmunkDebugDrawPointLineScalecxx . . $ ChipmunkDebugDrawPointLineScale.;
254 float r = outset - inset;
255
256 Vertexcxx . . $ Vertex# *vertexes = push_vertexescxx . . $ push_vertexes(19a9b1b0b1bd3c57).(4*count, indexes, 3*(5*count - 2));
257 for(int i=0; i<count; i++){
258 cpVectcxx . . $ cpVect# v0 = verts[i];
259 cpVectcxx . . $ cpVect# v_prev = verts[(i+(count - 1))%count];
260 cpVectcxx . . $ cpVect# v_next = verts[(i+(count + 1))%count];
261
262 cpVectcxx . . $ cpVect# n1 = cpvnormalizecxx . . $ cpvnormalize(e06142a62109ae08).(cpvrperpcxx . . $ cpvrperp(e06142a62109ae08).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(v0, v_prev)));
263 cpVectcxx . . $ cpVect# n2 = cpvnormalizecxx . . $ cpvnormalize(e06142a62109ae08).(cpvrperpcxx . . $ cpvrperp(e06142a62109ae08).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(v_next, v0)));
264 cpVectcxx . . $ cpVect# of = cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(n1, n2), 1.0/(cpvdotcxx . . $ cpvdot(7d57c1c4dd559d53).(n1, n2) + 1.0f));
265 cpVectcxx . . $ cpVect# v = cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(v0, cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(of, inset));
266
267 vertexes[4*i + 0] = (Vertexcxx . . $ Vertex#){{(float)v.xcxx . . $ cpVect#x., (float)v.ycxx . . $ cpVect#y.}, {0.0f, 0.0f}, 0.0f, fill, outline};
268 vertexes[4*i + 1] = (Vertexcxx . . $ Vertex#){{(float)v.xcxx . . $ cpVect#x., (float)v.ycxx . . $ cpVect#y.}, {(float)n1.xcxx . . $ cpVect#x., (float)n1.ycxx . . $ cpVect#y.}, r, fill, outline};
269 vertexes[4*i + 2] = (Vertexcxx . . $ Vertex#){{(float)v.xcxx . . $ cpVect#x., (float)v.ycxx . . $ cpVect#y.}, {(float)of.xcxx . . $ cpVect#x., (float)of.ycxx . . $ cpVect#y.}, r, fill, outline};
270 vertexes[4*i + 3] = (Vertexcxx . . $ Vertex#){{(float)v.xcxx . . $ cpVect#x., (float)v.ycxx . . $ cpVect#y.}, {(float)n2.xcxx . . $ cpVect#x., (float)n2.ycxx . . $ cpVect#y.}, r, fill, outline};
271 }
272 }
273
274 void ChipmunkDebugDrawBBcxx . . $ ChipmunkDebugDrawBB(a084cc6f3de926d8).(cpBBcxx . . $ cpBB# bb, cpSpaceDebugColorcxx . . $ cpSpaceDebugColor# color)
275 {
276 cpVectcxx . . $ cpVect# verts[] = {
277 cpvcxx . . $ cpv(3142d57d978b2176).(bb.rcxx . . $ cpBB#r., bb.bcxx . . $ cpBB#b.),
278 cpvcxx . . $ cpv(3142d57d978b2176).(bb.rcxx . . $ cpBB#r., bb.tcxx . . $ cpBB#t.),
279 cpvcxx . . $ cpv(3142d57d978b2176).(bb.lcxx . . $ cpBB#l., bb.tcxx . . $ cpBB#t.),
280 cpvcxx . . $ cpv(3142d57d978b2176).(bb.lcxx . . $ cpBB#l., bb.bcxx . . $ cpBB#b.),
281 };
282 ChipmunkDebugDrawPolygoncxx . . $ ChipmunkDebugDrawPolygon(6db671fc658f3d5c).(4, verts, 0.0f, color, LAColorcxx . . $ LAColor(197b9b65f197505a).(0, 0));
283 }
284
285 void
286 ChipmunkDebugDrawFlushRenderercxx . . $ ChipmunkDebugDrawFlushRenderer(49f6e7a06ebc5aa8).(void)
287 {
288 cpTransformcxx . . $ cpTransform# t = ChipmunkDebugDrawVPMatrixcxx . . $ ChipmunkDebugDrawVPMatrix.;
289 Uniformscxx . . $ Uniforms# uniforms = {
290 .U_vp_matrix = {(float)t.acxx . . $ cpTransform#a. , (float)t.bcxx . . $ cpTransform#b. , 0.0f, 0.0f, (float)t.ccxx . . $ cpTransform#c. , (float)t.dcxx . . $ cpTransform#d. , 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, (float)t.txcxx . . $ cpTransform#tx., (float)t.tycxx . . $ cpTransform#ty., 0.0f, 1.0f},
291 };
292
293 sg_update_buffercxx . . $ sg_update_buffer(5c59391e5d00dba1).(VertexBuffercxx . . $ VertexBuffer., Vertexescxx . . $ Vertexes., VertexCountcxx . . $ VertexCount.*sizeof(Vertexcxx . . $ Vertex#));
294 sg_update_buffercxx . . $ sg_update_buffer(5c59391e5d00dba1).(IndexBuffercxx . . $ IndexBuffer., Indexescxx . . $ Indexes., IndexCountcxx . . $ IndexCount.*sizeof(Indexcxx . . $ Index#));
295
296 sg_apply_pipelinecxx . . $ sg_apply_pipeline(fa06e78c216ede9c).(pipelinecxx . . $ pipeline.);
297 sg_apply_bindingscxx . . $ sg_apply_bindings(5f6aac639b109626).(&bindingscxx . . $ bindings.);
298 sg_apply_uniformscxx . . $ sg_apply_uniforms(d4a2e1eb7e556ec4).(SG_SHADERSTAGE_VScxx . . $ SG_SHADERSTAGE_VS., 0, &uniforms, sizeof(Uniformscxx . . $ Uniforms#));
299 sg_drawcxx . . $ sg_draw(b1146eedae1e1d0b).(0, IndexCountcxx . . $ IndexCount., 1);
300 }
301
302 void
303 ChipmunkDebugDrawClearRenderercxx . . $ ChipmunkDebugDrawClearRenderer(49f6e7a06ebc5aa8).(void)
304 {
305 VertexCountcxx . . $ VertexCount. = IndexCountcxx . . $ IndexCount. = 0;
306 }
307
308
309 static size_t PushedVertexCountcxx . . $ PushedVertexCount., PushedIndexCountcxx . . $ PushedIndexCount.;
310
311 void
312 ChipmunkDebugDrawPushRenderercxx . . $ ChipmunkDebugDrawPushRenderer(49f6e7a06ebc5aa8).(void)
313 {
314 PushedVertexCountcxx . . $ PushedVertexCount. = VertexCountcxx . . $ VertexCount.;
315 PushedIndexCountcxx . . $ PushedIndexCount. = IndexCountcxx . . $ IndexCount.;
316 }
317
318 void
319 ChipmunkDebugDrawPopRenderercxx . . $ ChipmunkDebugDrawPopRenderer(49f6e7a06ebc5aa8).(void)
320 {
321 VertexCountcxx . . $ VertexCount. = PushedVertexCountcxx . . $ PushedVertexCount.;
322 IndexCountcxx . . $ IndexCount. = PushedIndexCountcxx . . $ PushedIndexCount.;
323 }