Port line debug to SP, removing all unicolor code too

This commit is contained in:
Benau 2018-01-03 15:28:29 +08:00
parent 2eabf87ffe
commit 1de1cdf530
7 changed files with 65 additions and 113 deletions

View File

@ -23,7 +23,6 @@
#ifdef AI_DEBUG
# include "graphics/irr_driver.hpp"
# include "graphics/stk_tex_manager.hpp"
#endif
#include "graphics/show_curve.hpp"
#include "graphics/slip_stream.hpp"
@ -96,8 +95,6 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
i==2 ? 128 : 0);
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
m_debug_sphere[i]->setVisible(false);
m_debug_sphere[i]->setMaterialTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_debug_sphere[i]->setMaterialTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_debug_sphere[m_point_selection_algorithm]->setVisible(true);
m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0));

View File

@ -23,7 +23,6 @@
#ifdef AI_DEBUG
# include "graphics/irr_driver.hpp"
# include "graphics/stk_tex_manager.hpp"
#endif
#include "graphics/show_curve.hpp"
#include "graphics/slip_stream.hpp"
@ -102,8 +101,6 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
i==2 ? 128 : 0);
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
m_debug_sphere[i]->setVisible(false);
m_debug_sphere[i]->setMaterialTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
m_debug_sphere[i]->setMaterialTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_debug_sphere[m_point_selection_algorithm]->setVisible(true);
m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0));

View File

@ -21,9 +21,10 @@
#include "animations/animation_base.hpp"
#include "animations/ipo.hpp"
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/show_curve.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/sp/sp_base.hpp"
#include "graphics/sp/sp_dynamic_draw_call.hpp"
#include "io/xml_node.hpp"
#include "items/flyable.hpp"
#include "karts/abstract_kart.hpp"
@ -66,39 +67,24 @@ CheckCannon::CheckCannon(const XMLNode &node, unsigned int index)
}
if (UserConfigParams::m_check_debug)
{
video::SMaterial material;
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
material.setFlag(video::EMF_LIGHTING, false);
material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
scene::IMesh *mesh = irr_driver->createQuadMesh(&material,
/*create mesh*/true);
scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0);
assert(buffer->getVertexType() == video::EVT_STANDARD);
irr::video::S3DVertex* vertices
= (video::S3DVertex*)buffer->getVertices();
m_debug_target_dy_dc = std::make_shared<SP::SPDynamicDrawCall>
(scene::EPT_TRIANGLE_STRIP, SP::getSPShader("additive"),
material_manager->getSPMaterial("additive"));
SP::addDynamicDrawCall(m_debug_target_dy_dc);
m_debug_target_dy_dc->getVerticesVector().resize(4);
auto& vertices = m_debug_target_dy_dc->getVerticesVector();
Vec3 height(0, 3, 0);
vertices[0].Pos = m_target_left.toIrrVector();
vertices[1].Pos = m_target_right.toIrrVector();
vertices[2].Pos = Vec3(m_target_right + height).toIrrVector();
vertices[3].Pos = Vec3(m_target_left + height).toIrrVector();
for (unsigned int i = 0; i<4; i++)
vertices[0].m_position = m_target_left.toIrrVector();
vertices[1].m_position = m_target_right.toIrrVector();
vertices[2].m_position = Vec3(m_target_left + height).toIrrVector();
vertices[3].m_position = Vec3(m_target_right + height).toIrrVector();
for (unsigned int i = 0; i < 4; i++)
{
vertices[i].Color = m_active_at_reset
vertices[i].m_color = m_active_at_reset
? video::SColor(128, 255, 0, 0)
: video::SColor(128, 128, 128, 128);
}
buffer->recalculateBoundingBox();
buffer->getMaterial().setTexture(0, STKTexManager::getInstance()
->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
buffer->getMaterial().setTexture(1, STKTexManager::getInstance()
->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(2, STKTexManager::getInstance()
->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().BackfaceCulling = false;
//mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_target_node = irr_driver->addMesh(mesh, "checkdebug");
mesh->drop();
m_debug_target_dy_dc->recalculateBoundingBox();
}
#endif // DEBUG AND !SERVER_ONLY
@ -114,6 +100,8 @@ CheckCannon::~CheckCannon()
#if defined(DEBUG) && !defined(SERVER_ONLY)
if(UserConfigParams::m_track_debug)
delete m_show_curve;
if (m_debug_target_dy_dc)
m_debug_target_dy_dc->removeFromSP();
#endif
} // ~CheckCannon
@ -125,18 +113,13 @@ void CheckCannon::changeDebugColor(bool is_active)
#if defined(DEBUG) && !defined(SERVER_ONLY)
CheckLine::changeDebugColor(is_active);
/* scene::IMesh *mesh = m_debug_target_node->getMesh();
scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0);
irr::video::S3DVertex* vertices
= (video::S3DVertex*)buffer->getVertices();
video::SColor color = is_active ? video::SColor(192, 255, 0, 0)
: video::SColor(192, 128, 128, 128);
for (unsigned int i = 0; i<4; i++)
for (unsigned int i = 0; i < 4; i++)
{
vertices[i].Color = color;
m_debug_target_dy_dc->getVerticesVector()[i].m_color = color;
}
buffer->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(color));
*/
m_debug_target_dy_dc->setUpdateOffset(0);
#endif
} // changeDebugColor

View File

@ -29,6 +29,11 @@ class Ipo;
class ShowCurve;
class XMLNode;
namespace SP
{
class SPDynamicDrawCall;
}
/**
* \brief Implements a simple checkline that will cause a kart to be
* shot to a specified point.
@ -48,10 +53,10 @@ private:
#ifdef DEBUG
/** If track debugging is enabled, this will show the the curve of
* the cannon in the race. */
ShowCurve * m_show_curve;
ShowCurve* m_show_curve;
/** Used to display debug information about checklines. */
scene::ISceneNode *m_debug_target_node;
std::shared_ptr<SP::SPDynamicDrawCall> m_debug_target_dy_dc;
#endif
std::vector<Flyable*> m_all_flyables;
std::vector<Vec3> m_flyable_previous_position;

View File

@ -20,7 +20,9 @@
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/sp/sp_base.hpp"
#include "graphics/sp/sp_dynamic_draw_call.hpp"
#include "io/xml_node.hpp"
#include "karts/abstract_kart.hpp"
#include "modes/linear_world.hpp"
@ -74,56 +76,38 @@ CheckLine::CheckLine(const XMLNode &node, unsigned int index)
if(UserConfigParams::m_check_debug)
{
#ifndef SERVER_ONLY
video::SMaterial material;
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
material.setFlag(video::EMF_LIGHTING, false);
material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
scene::IMesh *mesh = irr_driver->createQuadMesh(&material,
/*create mesh*/true);
scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0);
assert(buffer->getVertexType()==video::EVT_STANDARD);
irr::video::S3DVertex* vertices
= (video::S3DVertex*)buffer->getVertices();
vertices[0].Pos = core::vector3df(p1.X,
m_min_height-m_under_min_height,
p1.Y);
vertices[1].Pos = core::vector3df(p2.X,
m_min_height-m_under_min_height,
p2.Y);
vertices[2].Pos = core::vector3df(p2.X,
m_min_height+m_over_min_height,
p2.Y);
vertices[3].Pos = core::vector3df(p1.X,
m_min_height+m_over_min_height,
p1.Y);
for(unsigned int i=0; i<4; i++)
m_debug_dy_dc = std::make_shared<SP::SPDynamicDrawCall>
(scene::EPT_TRIANGLE_STRIP, SP::getSPShader("additive"),
material_manager->getSPMaterial("additive"));
SP::addDynamicDrawCall(m_debug_dy_dc);
m_debug_dy_dc->getVerticesVector().resize(4);
auto& vertices = m_debug_dy_dc->getVerticesVector();
vertices[0].m_position = core::vector3df(p1.X,
m_min_height - m_under_min_height, p1.Y);
vertices[1].m_position = core::vector3df(p2.X,
m_min_height - m_under_min_height, p2.Y);
vertices[2].m_position = core::vector3df(p1.X,
m_min_height + m_over_min_height, p1.Y);
vertices[3].m_position = core::vector3df(p2.X,
m_min_height + m_over_min_height, p2.Y);
for(unsigned int i = 0; i < 4; i++)
{
vertices[i].Color = m_active_at_reset
? video::SColor(128, 255, 0, 0)
: video::SColor(128, 128, 128, 128);
vertices[i].m_color = m_active_at_reset
? video::SColor(128, 255, 0, 0)
: video::SColor(128, 128, 128, 128);
}
buffer->recalculateBoundingBox();
buffer->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(128, 255, 105, 180)));
buffer->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
buffer->getMaterial().BackfaceCulling = false;
//mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_node = irr_driver->addMesh(mesh, "checkdebug");
mesh->drop();
m_debug_dy_dc->recalculateBoundingBox();
#endif
}
else
{
m_debug_node = NULL;
}
} // CheckLine
// ----------------------------------------------------------------------------
CheckLine::~CheckLine()
{
if(m_debug_node)
irr_driver->removeNode(m_debug_node);
if (m_debug_dy_dc)
{
m_debug_dy_dc->removeFromSP();
}
} // CheckLine
// ----------------------------------------------------------------------------
@ -149,22 +133,14 @@ void CheckLine::resetAfterKartMove(unsigned int kart_index)
// ----------------------------------------------------------------------------
void CheckLine::changeDebugColor(bool is_active)
{
assert(m_debug_node);
/*scene::IMesh *mesh = m_debug_node->getMesh();
scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0);
irr::video::S3DVertex* vertices
= (video::S3DVertex*)buffer->getVertices();
assert(m_debug_dy_dc);
video::SColor color = is_active ? video::SColor(192, 255, 0, 0)
: video::SColor(192, 128, 128, 128);
for(unsigned int i=0; i<4; i++)
for(unsigned int i = 0; i < 4; i++)
{
vertices[i].Color = color;
m_debug_dy_dc->getVerticesVector()[i].m_color = color;
}
#ifndef SERVER_ONLY
buffer->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(color));
#endif
*/
m_debug_dy_dc->setUpdateOffset(0);
} // changeDebugColor
// ----------------------------------------------------------------------------

View File

@ -22,6 +22,7 @@
#include <ISceneNode.h>
#include <line2d.h>
#include <vector2d.h>
#include <memory>
using namespace irr;
#include "tracks/check_structure.hpp"
@ -29,6 +30,11 @@ using namespace irr;
class XMLNode;
class CheckManager;
namespace SP
{
class SPDynamicDrawCall;
}
/**
* \brief Implements a simple checkline.
* It's a finite line with 2 endpoints in 2d
@ -65,7 +71,7 @@ private:
std::vector<bool> m_previous_sign;
/** Used to display debug information about checklines. */
scene::ISceneNode *m_debug_node;
std::shared_ptr<SP::SPDynamicDrawCall> m_debug_dy_dc;
/** How much a kart is allowed to be under the minimum height of a
* quad and still considered to be able to cross it. */

View File

@ -816,18 +816,6 @@ void Track::createPhysicsModel(unsigned int main_track_count)
{
verts[i].Color = color;
}
// Color
#ifndef SERVER_ONLY
mb->getMaterial().setTexture(0, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 105, 180)));
#endif
irr_driver->grabAllTextures(mesh);
// Gloss
#ifndef SERVER_ONLY
mb->getMaterial().setTexture(1, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
// Colorization mask
mb->getMaterial().setTexture(2, STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
#endif
}
else
irr_driver->removeNode(m_static_physics_only_nodes[i]);