From 68eb4eb3598f81ffcc7062cefd183db1261244a0 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sun, 28 Jun 2015 19:00:25 -0400 Subject: [PATCH] Start work to control particle emitters from scripts, and allow getting kart velocity from script --- src/scriptengine/script_kart.cpp | 11 ++++++++++- src/tracks/track_object_presentation.cpp | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/scriptengine/script_kart.cpp b/src/scriptengine/script_kart.cpp index 9e827c65a..f16462c12 100644 --- a/src/scriptengine/script_kart.cpp +++ b/src/scriptengine/script_kart.cpp @@ -100,7 +100,7 @@ namespace Scripting } /** Sets the kart's velocity to the specified value. */ - void setVelocity(int idKart, Vec3* position) + void setVelocity(int idKart, SimpleVec3* position) { float x = position->getX(); float y = position->getY(); @@ -110,6 +110,14 @@ namespace Scripting kart->setVelocity(btVector3(x, y, z)); } + /** Gets the kart's velocity */ + SimpleVec3 getVelocity(int idKart) + { + AbstractKart* kart = World::getWorld()->getKart(idKart); + btVector3 velocity = kart->getVelocity(); + return SimpleVec3(velocity.getX(), velocity.getY(), velocity.getZ()); + } + /** @}*/ /** @}*/ @@ -122,6 +130,7 @@ namespace Scripting r = engine->RegisterGlobalFunction("void setVelocity(int id, const Vec3 &in)", asFUNCTION(setVelocity), asCALL_CDECL); assert(r >= 0); //r = engine->RegisterGlobalFunction("void jumpTo(int id, float x, float y)", asFUNCTION(jumpTo), asCALL_GENERIC); assert(r >= 0); r = engine->RegisterGlobalFunction("Vec3 getLocation(int id)", asFUNCTION(getLocation), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalFunction("Vec3 getVelocity(int id)", asFUNCTION(getVelocity), asCALL_CDECL); assert(r >= 0); } void registerScriptEnums(asIScriptEngine *engine) diff --git a/src/tracks/track_object_presentation.cpp b/src/tracks/track_object_presentation.cpp index f24f6b837..cf6dd3547 100644 --- a/src/tracks/track_object_presentation.cpp +++ b/src/tracks/track_object_presentation.cpp @@ -784,6 +784,9 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles( xml_node.get("clip_distance", &clip_distance); xml_node.get("conditions", &m_trigger_condition); + bool auto_emit = true; + xml_node.get("auto_emit", &auto_emit); + try { ParticleKind* kind = ParticleKindManager::get()->getParticles(path); @@ -810,7 +813,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles( m_emitter = emitter; } - if (m_trigger_condition.size() > 0) + if (m_trigger_condition.size() > 0 || !auto_emit) { m_emitter->setCreationRateAbsolute(0.0f); }