Skip to content

Commit

Permalink
collision causes basic terrain manipulation (at collision volume llf …
Browse files Browse the repository at this point in the history
…currently...) #92
  • Loading branch information
kateyy committed Feb 17, 2014
1 parent b1e40b4 commit ba3186a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libelemate/particles/particlecollision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "particlescriptaccess.h"
#include "particlegroup.h"
#include "lua/luawrapper.h"
#include "terrain/terraininteraction.h"

std::list<ParticleCollision::IntersectionBox> ParticleCollision::debug_intersectionBoxes;

Expand All @@ -33,16 +34,19 @@ void extractPointsInside(const std::vector<vec3> & points, const AxisAlignedBoun
ParticleCollision::ParticleCollision(ParticleScriptAccess & psa)
: m_psa(psa)
, m_lua(new LuaWrapper())
, m_terrainInteraction(new TerrainInteraction("bedrock"))
{
m_lua->loadScript("scripts/collision.lua");
m_psa.registerLuaFunctions(*m_lua);
m_terrainInteraction->registerLuaFunctions(*m_lua);

registerLuaFunctions();
}

ParticleCollision::~ParticleCollision()
{
delete m_lua;
delete m_terrainInteraction;
}

void ParticleCollision::registerLuaFunctions()
Expand Down
2 changes: 2 additions & 0 deletions libelemate/particles/particlecollision.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace glowutils {
class ParticleScriptAccess;
class ParticleGroup;
class LuaWrapper;
class TerrainInteraction;

class ParticleCollision
{
Expand All @@ -34,6 +35,7 @@ class ParticleCollision
protected:
ParticleScriptAccess & m_psa;
LuaWrapper * m_lua;
TerrainInteraction * m_terrainInteraction;

/** Register my functions that can be called from lua.
* If a relevant collision occurs, this class will call elementReaction() in lua. Lua functions called on this class
Expand Down
2 changes: 1 addition & 1 deletion libelemate/terrain/terraininteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,5 @@ void TerrainInteraction::registerLuaFunctions(LuaWrapper & lua)
lua.Register("terrain_gatherElement", func4);
lua.Register("terrain_terrainHeightAt", func5);
lua.Register("terrain_heightGrab", func6);
lua.Register("setInteractElement", func7);
lua.Register("terrain_setInteractElement", func7);
}
2 changes: 2 additions & 0 deletions scripts/collision.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ function collisionWaterLava(waterGroup, lavaGroup)
-- and later.. check that ratio between the two particles types, the release functions return a number of particles
-- now create bedrock where lava was removed
pc_createFromRemembered("bedrock")
terrain_setInteractElement("bedrock");
terrain_dropElement(collisionLlf[1], collisionLlf[3], 0.2);
end

function enlargeBox(llf, urb, delta)
Expand Down

0 comments on commit ba3186a

Please sign in to comment.