Skip to content

Commit 18e9e77

Browse files
committed
Add members for Lines
1 parent 5911bf3 commit 18e9e77

File tree

1 file changed

+46
-8
lines changed
  • Sources/GateEngine/System/Rendering/Drawables

1 file changed

+46
-8
lines changed

Sources/GateEngine/System/Rendering/Drawables/Scene.swift

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,45 +203,83 @@
203203

204204
/** Adds lines to the scene for rendering.
205205
- parameter lines: The lines to draw.
206-
- parameter material: The color information used to draw the geometry.
207206
- parameter transform: Describes how the lines instance should be positioned and scaled relative to the scene.
208207
- parameter flags: Options to customize how drawing is handled.
209208
- Explicitly instances the geometry as it's own batch. Use this for known instancing like particles.
210209
*/
211210
@_transparent
212211
public mutating func insert(
213212
_ lines: Lines,
214-
withMaterial material: Material,
215213
at transform: Transform3,
216214
flags: SceneElementFlags = .default
217215
) {
218-
self.insert(lines, withMaterial: material, at: [transform], flags: flags)
216+
self.insert(lines, at: [transform], flags: flags)
219217
}
220218

221219
/** Adds lines to the scene for rendering.
222220
- parameter lines: The lines to draw.
223-
- parameter material: The color information used to draw the geometry.
224221
- parameter transforms: Describes how each lines instance should be positioned and scaled relative to the scene.
225222
- parameter flags: Options to customize how drawing is handled.
226223
- Explicitly instances the geometry as it's own batch. Use this for known instancing like particles.
227224
*/
228225
@inlinable @inline(__always)
229226
public mutating func insert(
230227
_ lines: Lines,
231-
withMaterial material: Material,
232228
at transforms: [Transform3],
233229
flags: SceneElementFlags = .default
234230
) {
235231
let command = DrawCommand(
236232
resource: .lines(lines),
237233
transforms: transforms,
238-
material: material,
239-
vsh: .standard,
234+
material: Material(color: .vertexColors),
235+
vsh: .vertexColors,
240236
fsh: .vertexColor,
241237
flags: flags.drawCommandFlags(withPrimitive: .line)
242238
)
243239
self.insert(command)
244240
}
241+
242+
/** Adds lines to the scene for rendering.
243+
- parameter lines: The lines to draw.
244+
- parameter color: The color information used to draw the geometry.
245+
- parameter transform: Describes how the lines instance should be positioned and scaled relative to the scene.
246+
- parameter flags: Options to customize how drawing is handled.
247+
- Explicitly instances the geometry as it's own batch. Use this for known instancing like particles.
248+
*/
249+
@_transparent
250+
public mutating func insert(
251+
_ lines: Lines,
252+
withColor color: Color,
253+
at transform: Transform3,
254+
flags: SceneElementFlags = .default
255+
) {
256+
self.insert(lines, withColor: color, at: [transform], flags: flags)
257+
}
258+
259+
/** Adds lines to the scene for rendering.
260+
- parameter lines: The lines to draw.
261+
- parameter color: The color information used to draw the geometry.
262+
- parameter transforms: Describes how each lines instance should be positioned and scaled relative to the scene.
263+
- parameter flags: Options to customize how drawing is handled.
264+
- Explicitly instances the geometry as it's own batch. Use this for known instancing like particles.
265+
*/
266+
@inlinable @inline(__always)
267+
public mutating func insert(
268+
_ lines: Lines,
269+
withColor color: Color,
270+
at transforms: [Transform3],
271+
flags: SceneElementFlags = .default
272+
) {
273+
let command = DrawCommand(
274+
resource: .lines(lines),
275+
transforms: transforms,
276+
material: Material(color: color),
277+
vsh: .standard,
278+
fsh: .materialColor,
279+
flags: flags.drawCommandFlags(withPrimitive: .line)
280+
)
281+
self.insert(command)
282+
}
245283

246284
@inlinable @inline(__always)
247285
public mutating func insert(
@@ -458,7 +496,7 @@ public struct SceneElementFlags: OptionSet, Hashable {
458496
@_transparent
459497
public func drawCommandFlags(withPrimitive primitive: DrawCommand.Flags.Primitive, blendMode: DrawCommand.Flags.BlendMode = .normal) -> DrawCommand.Flags {
460498
let cull: DrawCommand.Flags.Cull = self.contains(.cullBackface) ? .back : .disabled
461-
let depthTest: DrawCommand.Flags.DepthTest = self.contains(.disableDepthCull) ? .always : .less
499+
let depthTest: DrawCommand.Flags.DepthTest = self.contains(.disableDepthCull) ? .always : .lessEqual
462500
let depthWrite: DrawCommand.Flags.DepthWrite =
463501
self.contains(.disableDepthWrite) ? .disabled : .enabled
464502
return DrawCommand.Flags(

0 commit comments

Comments
 (0)