refactored particleDebugger into its' own file
This commit is contained in:
parent
85c18f29ec
commit
7664349913
|
|
@ -0,0 +1,108 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const backlog = @import("Backlog");
|
||||||
|
const core = backlog.core;
|
||||||
|
const rend = backlog.rend;
|
||||||
|
const imgui = backlog.imgui;
|
||||||
|
const ig = imgui.api;
|
||||||
|
|
||||||
|
const ItemWidth = 80;
|
||||||
|
|
||||||
|
pub const ParticleDebugger = struct {
|
||||||
|
editParticle: ?core.Entity = null,
|
||||||
|
savedGravity: core.Vectorf = .{},
|
||||||
|
|
||||||
|
pub fn init() ParticleDebugger {
|
||||||
|
return .{};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn displayRandRangeImgui(comptime Name: []const u8, range: *rend.particles.ParticleRandRangef) void {
|
||||||
|
ig.textFmt(Name, .{}) catch {};
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
ig.setNextItemWidth(ItemWidth);
|
||||||
|
_ = ig.inputFloat("Min##particleEd" ++ Name, &range.min, 1.0, 5.0, null, .{});
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
ig.setNextItemWidth(ItemWidth);
|
||||||
|
_ = ig.inputFloat("Max##particleEd" ++ Name, &range.max, 1.0, 5.0, null, .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn editVector(comptime Name: []const u8, range: *core.Vectorf) void {
|
||||||
|
ig.textFmt(Name, .{}) catch {};
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
ig.setNextItemWidth(ItemWidth);
|
||||||
|
_ = ig.inputFloat("X##particleEd" ++ Name, &range.x, 1.0, 5.0, null, .{});
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
ig.setNextItemWidth(ItemWidth);
|
||||||
|
_ = ig.inputFloat("Y##particleEd" ++ Name, &range.y, 1.0, 5.0, null, .{});
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
ig.setNextItemWidth(ItemWidth);
|
||||||
|
_ = ig.inputFloat("Z##particleEd" ++ Name, &range.z, 1.0, 5.0, null, .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn particleDebug(self: *@This()) void {
|
||||||
|
if (ig.begin("particleDebugger", null, .{})) {
|
||||||
|
var buffer: [256]u8 = undefined;
|
||||||
|
ig.textFmt("active particles: {d}", .{rend.context().particleRenderer.lastParticleCount}) catch unreachable;
|
||||||
|
for (rend.ParticleEmitter.BaseContainer.dense.items, 0..) |*emitter, i| {
|
||||||
|
ig.textFmt("emitter {d}", .{emitter.sparseIndex.index}) catch {};
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
if (ig.smallButton(std.fmt.bufPrintZ(&buffer, "edit##{d}", .{i}) catch unreachable)) {
|
||||||
|
self.editParticle = emitter.value.entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ig.end();
|
||||||
|
|
||||||
|
var checkbox: bool = true;
|
||||||
|
|
||||||
|
if (self.editParticle) |edit| {
|
||||||
|
if (edit.fetch(rend.ParticleEmitter)) |emitter| {
|
||||||
|
if (ig.begin("editParticle", null, .{})) {
|
||||||
|
displayRandRangeImgui("Acceleration", &emitter.particleAcceleration);
|
||||||
|
displayRandRangeImgui("Velocity", &emitter.particleVelocity);
|
||||||
|
displayRandRangeImgui("Life", &emitter.particleLife);
|
||||||
|
displayRandRangeImgui("Size", &emitter.particleSizeSpawn);
|
||||||
|
displayRandRangeImgui("spawnRate", &emitter.spawnRate);
|
||||||
|
|
||||||
|
if (emitter.gravity != null) {
|
||||||
|
checkbox = true;
|
||||||
|
} else {
|
||||||
|
checkbox = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ig.checkbox("hasGravity", &checkbox)) {
|
||||||
|
if (!checkbox) {
|
||||||
|
self.savedGravity = emitter.gravity.?;
|
||||||
|
emitter.gravity = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkbox) {
|
||||||
|
emitter.gravity = self.savedGravity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emitter.gravity != null) {
|
||||||
|
editVector("gravity", &emitter.gravity.?);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = ig.inputInt("maxParticles##particleEd", @ptrCast(&emitter.maxParticles), 1, 5, .{});
|
||||||
|
_ = ig.checkbox("showDebug", &emitter._showDebug);
|
||||||
|
_ = ig.checkbox("useLocalScene", &emitter.useLocalScene);
|
||||||
|
_ = ig.checkbox("billboard", &emitter.billboard);
|
||||||
|
|
||||||
|
if (ig.smallButton("alive")) {
|
||||||
|
emitter.state = .alive;
|
||||||
|
}
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
if (ig.smallButton("kill")) {
|
||||||
|
emitter.state = .dead;
|
||||||
|
}
|
||||||
|
ig.sameLine(0, 10);
|
||||||
|
if (ig.smallButton("pause")) {
|
||||||
|
emitter.state = .paused;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ig.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -6,5 +6,6 @@ pub const ObjectSpawner = @import("debuggers/objectSpawner.zig");
|
||||||
pub const RendererDebug = @import("debuggers/RendererDebug.zig");
|
pub const RendererDebug = @import("debuggers/RendererDebug.zig");
|
||||||
pub const EngineTool = @import("debuggers/EngineTool.zig");
|
pub const EngineTool = @import("debuggers/EngineTool.zig");
|
||||||
pub const PhysicsObjectList = @import("debuggers/PhysicsObjectList.zig");
|
pub const PhysicsObjectList = @import("debuggers/PhysicsObjectList.zig");
|
||||||
|
pub const ParticleDebugger = @import("debuggers/ParticleDebugger.zig");
|
||||||
|
|
||||||
pub const browser = @import("debuggers/fileBrowser.zig");
|
pub const browser = @import("debuggers/fileBrowser.zig");
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,13 @@ pub const ExternGameObject = struct {
|
||||||
tbMap: ?*bsp.maploader.TBMap = null,
|
tbMap: ?*bsp.maploader.TBMap = null,
|
||||||
physicsObjectsWindow: *extras.PhysicsObjectList = undefined,
|
physicsObjectsWindow: *extras.PhysicsObjectList = undefined,
|
||||||
fireTraceFilter: physics.IgnoreFixedBodiesFilter = .{},
|
fireTraceFilter: physics.IgnoreFixedBodiesFilter = .{},
|
||||||
|
particleDebugger: extras.ParticleDebugger.ParticleDebugger = undefined,
|
||||||
|
|
||||||
//lmao: bool = false,
|
//lmao: bool = false,
|
||||||
//lmao2: bool = true,
|
//lmao2: bool = true,
|
||||||
a: bool = false,
|
a: bool = false,
|
||||||
// lib: bool = false,
|
// lib: bool = false,
|
||||||
//s: u32 = 0x42,
|
//s: u32 = 0x42,
|
||||||
editParticle: ?core.Entity = null,
|
|
||||||
savedGravity: core.Vectorf = .{},
|
|
||||||
|
|
||||||
pub fn loadMap2(self: *@This()) !void {
|
pub fn loadMap2(self: *@This()) !void {
|
||||||
if (self.tbMap) |tbMap| {
|
if (self.tbMap) |tbMap| {
|
||||||
|
|
@ -71,104 +70,13 @@ pub const ExternGameObject = struct {
|
||||||
core.engine_log("map loaded", .{});
|
core.engine_log("map loaded", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
const ItemWidth = 80;
|
|
||||||
|
|
||||||
pub fn displayRandRangeImgui(comptime Name: []const u8, range: *rend.particles.ParticleRandRangef) void {
|
|
||||||
ig.textFmt(Name, .{}) catch {};
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
ig.setNextItemWidth(ItemWidth);
|
|
||||||
_ = ig.inputFloat("Min##particleEd" ++ Name, &range.min, 1.0, 5.0, null, .{});
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
ig.setNextItemWidth(ItemWidth);
|
|
||||||
_ = ig.inputFloat("Max##particleEd" ++ Name, &range.max, 1.0, 5.0, null, .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn editVector(comptime Name: []const u8, range: *core.Vectorf) void {
|
|
||||||
ig.textFmt(Name, .{}) catch {};
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
ig.setNextItemWidth(ItemWidth);
|
|
||||||
_ = ig.inputFloat("X##particleEd" ++ Name, &range.x, 1.0, 5.0, null, .{});
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
ig.setNextItemWidth(ItemWidth);
|
|
||||||
_ = ig.inputFloat("Y##particleEd" ++ Name, &range.y, 1.0, 5.0, null, .{});
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
ig.setNextItemWidth(ItemWidth);
|
|
||||||
_ = ig.inputFloat("Z##particleEd" ++ Name, &range.z, 1.0, 5.0, null, .{});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn particleDebug(self: *@This()) void {
|
|
||||||
if (ig.begin("particleDebugger", null, .{})) {
|
|
||||||
var buffer: [256]u8 = undefined;
|
|
||||||
ig.textFmt("active particles: {d}", .{rend.context().particleRenderer.lastParticleCount}) catch unreachable;
|
|
||||||
for (rend.ParticleEmitter.BaseContainer.dense.items, 0..) |*emitter, i| {
|
|
||||||
ig.textFmt("emitter {d}", .{emitter.sparseIndex.index}) catch {};
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
if (ig.smallButton(std.fmt.bufPrintZ(&buffer, "edit##{d}", .{i}) catch unreachable)) {
|
|
||||||
self.editParticle = emitter.value.entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ig.end();
|
|
||||||
|
|
||||||
var checkbox: bool = true;
|
|
||||||
|
|
||||||
if (self.editParticle) |edit| {
|
|
||||||
if (edit.fetch(rend.ParticleEmitter)) |emitter| {
|
|
||||||
if (ig.begin("editParticle", null, .{})) {
|
|
||||||
displayRandRangeImgui("Acceleration", &emitter.particleAcceleration);
|
|
||||||
displayRandRangeImgui("Velocity", &emitter.particleVelocity);
|
|
||||||
displayRandRangeImgui("Life", &emitter.particleLife);
|
|
||||||
displayRandRangeImgui("Size", &emitter.particleSizeSpawn);
|
|
||||||
displayRandRangeImgui("spawnRate", &emitter.spawnRate);
|
|
||||||
|
|
||||||
if (emitter.gravity != null) {
|
|
||||||
checkbox = true;
|
|
||||||
} else {
|
|
||||||
checkbox = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ig.checkbox("hasGravity", &checkbox)) {
|
|
||||||
if (!checkbox) {
|
|
||||||
self.savedGravity = emitter.gravity.?;
|
|
||||||
emitter.gravity = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkbox) {
|
|
||||||
emitter.gravity = self.savedGravity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emitter.gravity != null) {
|
|
||||||
editVector("gravity", &emitter.gravity.?);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = ig.inputInt("maxParticles##particleEd", @ptrCast(&emitter.maxParticles), 1, 5, .{});
|
|
||||||
_ = ig.checkbox("showDebug", &emitter._showDebug);
|
|
||||||
_ = ig.checkbox("useLocalScene", &emitter.useLocalScene);
|
|
||||||
_ = ig.checkbox("billboard", &emitter.billboard);
|
|
||||||
|
|
||||||
if (ig.smallButton("alive")) {
|
|
||||||
emitter.state = .alive;
|
|
||||||
}
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
if (ig.smallButton("kill")) {
|
|
||||||
emitter.state = .dead;
|
|
||||||
}
|
|
||||||
ig.sameLine(0, 10);
|
|
||||||
if (ig.smallButton("pause")) {
|
|
||||||
emitter.state = .paused;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ig.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator) !*@This() {
|
pub fn create(allocator: std.mem.Allocator) !*@This() {
|
||||||
const self = try Slack.create(allocator);
|
const self = try Slack.create(allocator);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.consoleWindow = imgui.utils.ConsoleWindow.init(allocator),
|
.consoleWindow = imgui.utils.ConsoleWindow.init(allocator),
|
||||||
|
.particleDebugger = extras.ParticleDebugger.ParticleDebugger.init(),
|
||||||
};
|
};
|
||||||
|
|
||||||
imgui.utils.addMenuFunc(self, "Input Stack Viewer", extras.inputDebugger.windowOpen);
|
imgui.utils.addMenuFunc(self, "Input Stack Viewer", extras.inputDebugger.windowOpen);
|
||||||
|
|
@ -323,7 +231,7 @@ pub const ExternGameObject = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.particleDebug();
|
self.particleDebugger.particleDebug();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue