added tcg/tcb instructions (toggle collision rendering); not fully working yet (problem in OpenEngine or MWScene)

actorid
Marc Zinnschlag 14 years ago
parent 8ebdd77772
commit 72a84356e2

@ -116,7 +116,7 @@ void MWScene::doPhysics (float duration, MWWorld::World& world,
MWWorld::DoingPhysics scopeGuard;
//set the DebugRenderingMode. To disable it,set it to 0
eng->setDebugRenderingMode(1);
// eng->setDebugRenderingMode(1);
//set the walkdirection to 0 (no movement) for every actor)
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
@ -204,3 +204,16 @@ void MWScene::toggleCollisionMode()
{
}
void MWScene::toggleRenderMode (int mode)
{
switch (mode)
{
case MWWorld::World::Render_CollisionDebug:
// TODO use a proper function instead of accessing the member variable
// directly.
eng->setDebugRenderingMode (!eng->isDebugCreated);
break;
}
}

@ -90,6 +90,11 @@ namespace MWRender
/// Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
void toggleCollisionMode();
/// Toggle render mode
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
/// when the mw*-refactoring is done.
void toggleRenderMode (int mode);
};
}

@ -103,4 +103,5 @@ op 0x20000fa-0x2000114: ModSkill
op 0x2000115-0x200012f: ModSKill, explicit reference
op 0x2000130: ToggleCollision
op 0x2000131: GetInterior
opcodes 0x2000132-0x3ffffff unused
op 0x2000132: ToggleCollsionDebug
opcodes 0x2000133-0x3ffffff unused

@ -90,6 +90,18 @@ namespace MWScript
}
};
class OpToggleCollisionDebug : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug);
}
};
const int opcodeXBox = 0x200000c;
const int opcodeOnActivate = 0x200000d;
@ -98,6 +110,7 @@ namespace MWScript
const int opcodeLockExplicit = 0x20005;
const int opcodeUnlock = 0x200008c;
const int opcodeUnlockExplicit = 0x200008d;
const int opcodeToggleCollisionDebug = 0x2000132;
void registerExtensions (Compiler::Extensions& extensions)
{
@ -106,6 +119,10 @@ namespace MWScript
extensions.registerInstruction ("activate", "", opcodeActivate);
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionDebug);
extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug);
extensions.registerInstruction ("tcb", "", opcodeToggleCollisionDebug);
extensions.registerInstruction ("tcg", "", opcodeToggleCollisionDebug);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -117,6 +134,7 @@ namespace MWScript
interpreter.installSegment3 (opcodeLockExplicit, new OpLock<ExplicitRef>);
interpreter.installSegment5 (opcodeUnlock, new OpUnlock<ImplicitRef>);
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock<ExplicitRef>);
interpreter.installSegment5 (opcodeToggleCollisionDebug, new OpToggleCollisionDebug);
}
}
}

@ -860,4 +860,9 @@ namespace MWWorld
{
mScene.toggleCollisionMode();
}
void World::toggleRenderMode (RenderMode mode)
{
mScene.toggleRenderMode (mode);
}
}

@ -50,6 +50,11 @@ namespace MWWorld
public:
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
enum RenderMode
{
Render_CollisionDebug
};
private:
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
@ -183,6 +188,9 @@ namespace MWWorld
void toggleCollisionMode();
///< Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
void toggleRenderMode (RenderMode mode);
///< Toggle a render mode.
};
}

Loading…
Cancel
Save