added features for local editing of some stuff
This commit is contained in:
parent
2046b1d7c8
commit
eaf1d2bcb7
|
|
@ -141,6 +141,8 @@ pub const ParticleEmitter = struct {
|
||||||
emitterMaxLife: f64 = 0.0,
|
emitterMaxLife: f64 = 0.0,
|
||||||
emitterShape: EmitterShape = .{ .spherical = .{} },
|
emitterShape: EmitterShape = .{ .spherical = .{} },
|
||||||
|
|
||||||
|
useLocalScene: bool = false,
|
||||||
|
|
||||||
_showDebug: bool = false,
|
_showDebug: bool = false,
|
||||||
|
|
||||||
entity: core.Entity = undefined,
|
entity: core.Entity = undefined,
|
||||||
|
|
@ -180,6 +182,7 @@ pub const ParticleEmitter = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.useLocalScene) {
|
||||||
switch (self.emitterShape) {
|
switch (self.emitterShape) {
|
||||||
.spherical => |spherical| {
|
.spherical => |spherical| {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
@ -194,6 +197,7 @@ pub const ParticleEmitter = struct {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn removeParticle(self: *@This(), i: usize) void {
|
pub fn removeParticle(self: *@This(), i: usize) void {
|
||||||
_ = self.life.swapRemove(i);
|
_ = self.life.swapRemove(i);
|
||||||
|
|
@ -237,7 +241,7 @@ pub const ParticleEmitter = struct {
|
||||||
const v = core.Vectorf{ .x = oneRand.getRange(), .y = oneRand.getRange(), .z = oneRand.getRange() };
|
const v = core.Vectorf{ .x = oneRand.getRange(), .y = oneRand.getRange(), .z = oneRand.getRange() };
|
||||||
const v2 = v.normalize();
|
const v2 = v.normalize();
|
||||||
|
|
||||||
const pva: ParticlePVA = .{
|
var pva: ParticlePVA = .{
|
||||||
.velocity = v2.fmul(self.particleVelocity.getRange()).toZm(),
|
.velocity = v2.fmul(self.particleVelocity.getRange()).toZm(),
|
||||||
.position = .{
|
.position = .{
|
||||||
radius.getRange(),
|
radius.getRange(),
|
||||||
|
|
@ -247,6 +251,11 @@ pub const ParticleEmitter = struct {
|
||||||
},
|
},
|
||||||
.acceleration = v2.fmul(self.particleAcceleration.getRange()).toZm(),
|
.acceleration = v2.fmul(self.particleAcceleration.getRange()).toZm(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!self.useLocalScene) {
|
||||||
|
const scenePos = core.zm.mul(pva.position, self.entity.fetch(core.Scene).?.getPosRot().toTransform());
|
||||||
|
pva.position = scenePos;
|
||||||
|
}
|
||||||
return pva;
|
return pva;
|
||||||
},
|
},
|
||||||
.conal => |conal| {
|
.conal => |conal| {
|
||||||
|
|
@ -291,6 +300,7 @@ pub const ParticleEmitter = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn updateFinals(self: *@This()) void {
|
pub fn updateFinals(self: *@This()) void {
|
||||||
|
if (self.useLocalScene) {
|
||||||
const scene = self.entity.fetch(core.Scene).?;
|
const scene = self.entity.fetch(core.Scene).?;
|
||||||
const transform = scene.getPosRot().toTransform();
|
const transform = scene.getPosRot().toTransform();
|
||||||
|
|
||||||
|
|
@ -299,6 +309,12 @@ pub const ParticleEmitter = struct {
|
||||||
|
|
||||||
self.finals.items[i] = core.zm.mul(p, transform);
|
self.finals.items[i] = core.zm.mul(p, transform);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (self.particlesPVA.items, 0..) |pva, i| {
|
||||||
|
const p = core.zm.translationV(pva.position);
|
||||||
|
self.finals.items[i] = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var t_whiteName: core.Name = core.DefineName("t_white");
|
var t_whiteName: core.Name = core.DefineName("t_white");
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,14 @@ pub const ExternGameObject = struct {
|
||||||
.mass_properties_override = .{ .mass = 12 },
|
.mass_properties_override = .{ .mass = 12 },
|
||||||
.override_mass_properties = .calc_inertia,
|
.override_mass_properties = .calc_inertia,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const particle = box2.addComponent(rend.ParticleEmitter).?;
|
||||||
|
particle.start();
|
||||||
|
particle.gravity = .{ .y = 1.0 };
|
||||||
|
particle.particleVelocity = .{ .min = 0.6, .max = 1.2 };
|
||||||
|
particle.particleLife = .{ .min = 5, .max = 6 };
|
||||||
|
var name = core.MakeName("t_pixelSmoke");
|
||||||
|
particle.texture = rend.getTexture(&name).?;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn onAltFire(ctx: ?*anyopaque, _: core.ActionEvent) void {
|
fn onAltFire(ctx: ?*anyopaque, _: core.ActionEvent) void {
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ pub const ParticleObject = struct {
|
||||||
const e = try core.createEntity();
|
const e = try core.createEntity();
|
||||||
|
|
||||||
const particle = e.addComponent(rend.ParticleEmitter).?;
|
const particle = e.addComponent(rend.ParticleEmitter).?;
|
||||||
particle._showDebug = true;
|
|
||||||
particle.start();
|
particle.start();
|
||||||
particle.gravity = .{ .y = -9.8 };
|
particle.gravity = .{ .y = -9.8 };
|
||||||
var name = core.MakeName("t_pixelSmoke");
|
var name = core.MakeName("t_pixelSmoke");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue