adding offsets

This commit is contained in:
peterino2 2025-05-30 19:45:38 -07:00
parent b9ddc72e73
commit 69203653fd
7 changed files with 45 additions and 54 deletions

View File

@ -141,7 +141,7 @@ pub fn addProgram(self: *BuildSystem, opts: AddProgramOptions) *std.Build.Module
b.getInstallStep().dependOn(self.nw_builder.getInstallStep());
run_exe.dependOn(b.getInstallStep());
// run_exe.dependOn(b.getInstallStep());
return mod;
}

View File

@ -1,4 +1,4 @@
pub var NeonObjectTable = core.EngineObjectVTable.from(@This(), "game.ExternGameObject");
pub var NeonObjectTable = core.EngineObjectVTable.from(@This(), "game.TopBar");
pub const Slack = core.SlackStruct(@This(), 256);
allocator: std.mem.Allocator,

View File

@ -488,6 +488,8 @@ pub const Context = struct {
self.debugTextCount = 0;
}
pub const destroy = deinit;
pub fn deinit(self: *@This()) void {
for (0..self.nodes.count()) |i| {
const maybeNode = self.nodes.indexToHandle(i);

View File

@ -19,7 +19,7 @@ first: bool = true,
rectPipeline: *gpu.GPUGraphicsPipeline = undefined,
// textPipeline: *gpu.GPUGraphicsPipeline = undefined,
pub var NeonObjectTable: core.EngineObjectVTable = core.EngineObjectVTable.from(@This());
pub var NeonObjectTable: core.EngineObjectVTable = core.EngineObjectVTable.from(@This(), "ui.runtime");
pub fn create(allocator: std.mem.Allocator) !*@This() {
const self: *@This() = try allocator.create(@This());

View File

@ -1,6 +1,5 @@
const std = @import("std");
pub const core = @import("core");
pub const api = @import("cimgui");
const rend = @import("rend");
pub const papyrus = @import("papyrus");
@ -12,24 +11,17 @@ pub const Module: core.ModuleDescription = .{
pub const PapyrusIntegration = @import("sgpu/papyrusSgpu.zig");
var gIntegration: *PapyrusIntegration = undefined;
pub fn start_module(spec: *core.SpecVariantMap, args: anytype, allocator: std.mem.Allocator) !void {
_ = args;
_ = spec;
_ = allocator;
gIntegration = try PapyrusIntegration.create(allocator);
try gIntegration.setup();
const ctx = try core.createObject(PapyrusIntegration, .{});
try ctx.setup();
}
// gets the main context under gIntegration
pub fn context() *papyrus.Context {
return gIntegration.screenContext;
}
pub fn runtime() *PapyrusIntegration {
return gIntegration;
}
// gets the main context
pub const context = core.EngineObject(PapyrusIntegration).get;
pub fn shutdown_module(allocator: std.mem.Allocator) void {
_ = allocator;

View File

@ -112,47 +112,46 @@ pub const ExternGameObject = struct {
pub fn tick(self: *@This(), dt: f64) void {
const rctx = rend.context();
_ = rctx;
_ = dt;
if (ig.begin("meh", null, .{})) {
// if (ig.checkbox("move lights ", null)) {}
ig.textFmt("info: - WASD to move, mouse to look,\n- Q and E to go up and down", .{}) catch return;
ig.textFmt("- shift to slow down camera speed", .{}) catch return;
ig.textFmt("- T to enable/disable mouse cursor", .{}) catch return;
ig.textFmt("- f2 to route all inputs to the doom player", .{}) catch return;
ig.textFmt("- movingLight checkbox makes the light stop moving with you", .{}) catch return;
if (ig.smallButton("reload map")) {
self.loadMap2() catch unreachable;
}
if (ig.smallButton("destroy map")) {
if (self.tbMap) |tbMap| {
core.engine_log("killing the map", .{});
tbMap.destroy();
self.tbMap = null;
}
}
if (core.getEngineObject(imgui.utils.TopBar)) |topbar| {
topbar.menuOpen = platform.context().isCursorEnabled();
}
ig.end();
if (platform.context().isCursorEnabled()) {
if (ig.begin("cursor", null, .{})) {
if (ig.begin("meh", null, .{})) {
// if (ig.checkbox("move lights ", null)) {}
ig.textFmt("info: - WASD to move, mouse to look,\n- Q and E to go up and down", .{}) catch return;
ig.textFmt("- shift to slow down camera speed", .{}) catch return;
ig.textFmt("- T to enable/disable mouse cursor", .{}) catch return;
ig.textFmt("- f2 to route all inputs to the doom player", .{}) catch return;
ig.textFmt("- movingLight checkbox makes the light stop moving with you", .{}) catch return;
if (ig.smallButton("reload map")) {
self.loadMap2() catch unreachable;
}
if (ig.smallButton("destroy map")) {
if (self.tbMap) |tbMap| {
core.engine_log("killing the map", .{});
tbMap.destroy();
self.tbMap = null;
}
}
}
ig.end();
if (platform.context().isCursorEnabled()) {
if (rend.context().activeCamera) |cam| {
const ray = cam.getNormalRayFromScreen(platform.getCursorPosition());
if (physics.traceLine(ray.start, ray.dir.fmul(10000), .{ .bodyFilter = &self.fireTraceFilter, .getNormalsSlow = false })) |r| {
core.debugSphere(r.point, 0.2, .{ .color = .{ .x = 1.0 }, .duration = 0 });
// core.debugLine(ray.start, ray.start.add(ray.dir.fmul(1000)), .{ .duration = 2.5 });
// physics.applyForce(r.body, ray.dir.fmul(400), r.point);
ig.textf("{d} {d} {d}", .{ r.point.x, r.point.y, r.point.z });
}
ig.textf("imgui mouse consumed {any}", .{platform.getInstance().imguiMouseConsumed});
}
}
ig.end();
}
//_ = self;
@ -170,13 +169,13 @@ pub const ExternGameObject = struct {
// }
// ig.end();
if (ig.begin("list of textures", null, .{})) {
var iterator = rctx.textureList.map.iterator();
while (iterator.next()) |i| {
ig.textf("{s}", .{i.value_ptr.*.name.utf8()});
}
}
ig.end();
// if (ig.begin("list of textures", null, .{})) {
// var iterator = rctx.textureList.map.iterator();
// while (iterator.next()) |i| {
// ig.textf("{s}", .{i.value_ptr.*.name.utf8()});
// }
// }
// ig.end();
// if (ig.begin("list of meshes", null, .{})) {
// ig.textf("number of meshes: {d}", .{rctx.meshPool.installedMeshes.count()});

View File

@ -175,8 +175,6 @@ pub fn prepare(self: *@This()) !void {
try self.objectSpawner.addSpawnFunction("empire", @import("empire.zig"));
try self.objectSpawner.addSpawnFunction("DamagedHelmet", DamagedHelmet);
ui.context().drawDebug = true;
try assets.loadList(assetReferences);
// self.videoplayer = try VideoPlayer.create(self.allocator);
// try self.videoplayer.startPlayback("LAPWING2.ogv");
@ -429,9 +427,9 @@ pub fn tick(self: *@This(), dt: f64) void {
// self.loadMap2() catch unreachable;
// show a window with the current camera's position
self.objectSpawner.windowOpen = !self.mouseLook;
if (!self.mouseLook) {
// self.engineTool.tick();
self.objectSpawner.windowOpen = !self.mouseLook;
//if (ig.begin("meh", null, .{})) {
//if (ig.checkbox("move lights ", &self.moveLight)) {}
//}