mirror of
https://github.com/overte-org/overte.git
synced 2025-04-18 07:56:25 +02:00
pass scriptable particle on collisions
This commit is contained in:
parent
9194a53410
commit
5057517b78
3 changed files with 8 additions and 10 deletions
|
@ -540,7 +540,7 @@ void Particle::runUpdateScript() {
|
|||
}
|
||||
}
|
||||
|
||||
void Particle::collisionWithParticle(unsigned int otherID) {
|
||||
void Particle::collisionWithParticle(Particle* other) {
|
||||
if (!_script.isEmpty()) {
|
||||
|
||||
QScriptEngine engine;
|
||||
|
@ -564,14 +564,12 @@ void Particle::collisionWithParticle(unsigned int otherID) {
|
|||
if (getParticlesScriptingInterface()) {
|
||||
QScriptValue particleScripterValue = engine.newQObject(getParticlesScriptingInterface());
|
||||
engine.globalObject().setProperty("Particles", particleScripterValue);
|
||||
printf("has Particles...\n");
|
||||
} else {
|
||||
printf("no Particles...\n");
|
||||
}
|
||||
|
||||
QScriptValue result = engine.evaluate(_script);
|
||||
|
||||
particleScriptable.emitCollisionWithParticle(otherID);
|
||||
ParticleScriptObject otherParticleScriptable(other);
|
||||
particleScriptable.emitCollisionWithParticle(&otherParticleScriptable);
|
||||
|
||||
if (getVoxelsScriptingInterface()) {
|
||||
getVoxelsScriptingInterface()->getPacketSender()->releaseQueuedMessages();
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
|
||||
void update();
|
||||
void collisionWithParticle(unsigned int otherID);
|
||||
void collisionWithParticle(Particle* other);
|
||||
|
||||
void debugDump() const;
|
||||
|
||||
|
@ -170,7 +170,7 @@ public:
|
|||
ParticleScriptObject(Particle* particle) { _particle = particle; }
|
||||
|
||||
void emitUpdate() { emit update(); }
|
||||
void emitCollisionWithParticle(uint32_t otherID) { emit collisionWithParticle(otherID); }
|
||||
void emitCollisionWithParticle(QObject* other) { emit collisionWithParticle(other); }
|
||||
void emitCollisionWithVoxel() { emit collisionWithVoxel(); }
|
||||
|
||||
public slots:
|
||||
|
@ -196,7 +196,7 @@ public slots:
|
|||
signals:
|
||||
void update();
|
||||
void collisionWithVoxel();
|
||||
void collisionWithParticle(unsigned int otherID);
|
||||
void collisionWithParticle(QObject* other);
|
||||
|
||||
private:
|
||||
Particle* _particle;
|
||||
|
|
|
@ -92,8 +92,8 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particle) {
|
|||
if (_particles->findSpherePenetration(center, radius, penetration, (void**)&penetratedParticle)) {
|
||||
|
||||
// let the particles run their collision scripts if they have them
|
||||
particle->collisionWithParticle(penetratedParticle->getID());
|
||||
penetratedParticle->collisionWithParticle(particle->getID());
|
||||
particle->collisionWithParticle(penetratedParticle);
|
||||
penetratedParticle->collisionWithParticle(particle);
|
||||
|
||||
penetration /= (float)TREE_SCALE;
|
||||
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
||||
|
|
Loading…
Reference in a new issue