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 #ifdef AI_DEBUG
# include "graphics/irr_driver.hpp" # include "graphics/irr_driver.hpp"
# include "graphics/stk_tex_manager.hpp"
#endif #endif
#include "graphics/show_curve.hpp" #include "graphics/show_curve.hpp"
#include "graphics/slip_stream.hpp" #include "graphics/slip_stream.hpp"
@ -96,8 +95,6 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
i==2 ? 128 : 0); i==2 ? 128 : 0);
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug); m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
m_debug_sphere[i]->setVisible(false); 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_debug_sphere[m_point_selection_algorithm]->setVisible(true);
m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0)); m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0));

View File

@ -23,7 +23,6 @@
#ifdef AI_DEBUG #ifdef AI_DEBUG
# include "graphics/irr_driver.hpp" # include "graphics/irr_driver.hpp"
# include "graphics/stk_tex_manager.hpp"
#endif #endif
#include "graphics/show_curve.hpp" #include "graphics/show_curve.hpp"
#include "graphics/slip_stream.hpp" #include "graphics/slip_stream.hpp"
@ -102,8 +101,6 @@ SkiddingAI::SkiddingAI(AbstractKart *kart)
i==2 ? 128 : 0); i==2 ? 128 : 0);
m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug); m_debug_sphere[i] = irr_driver->addSphere(1.0f, col_debug);
m_debug_sphere[i]->setVisible(false); 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_debug_sphere[m_point_selection_algorithm]->setVisible(true);
m_item_sphere = irr_driver->addSphere(1.0f, video::SColor(255, 0, 255, 0)); 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/animation_base.hpp"
#include "animations/ipo.hpp" #include "animations/ipo.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/show_curve.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 "io/xml_node.hpp"
#include "items/flyable.hpp" #include "items/flyable.hpp"
#include "karts/abstract_kart.hpp" #include "karts/abstract_kart.hpp"
@ -66,39 +67,24 @@ CheckCannon::CheckCannon(const XMLNode &node, unsigned int index)
} }
if (UserConfigParams::m_check_debug) if (UserConfigParams::m_check_debug)
{ {
video::SMaterial material; m_debug_target_dy_dc = std::make_shared<SP::SPDynamicDrawCall>
material.setFlag(video::EMF_BACK_FACE_CULLING, false); (scene::EPT_TRIANGLE_STRIP, SP::getSPShader("additive"),
material.setFlag(video::EMF_LIGHTING, false); material_manager->getSPMaterial("additive"));
material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; SP::addDynamicDrawCall(m_debug_target_dy_dc);
scene::IMesh *mesh = irr_driver->createQuadMesh(&material, m_debug_target_dy_dc->getVerticesVector().resize(4);
/*create mesh*/true); auto& vertices = m_debug_target_dy_dc->getVerticesVector();
scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0);
assert(buffer->getVertexType() == video::EVT_STANDARD);
irr::video::S3DVertex* vertices
= (video::S3DVertex*)buffer->getVertices();
Vec3 height(0, 3, 0); Vec3 height(0, 3, 0);
vertices[0].Pos = m_target_left.toIrrVector(); vertices[0].m_position = m_target_left.toIrrVector();
vertices[1].Pos = m_target_right.toIrrVector(); vertices[1].m_position = m_target_right.toIrrVector();
vertices[2].Pos = Vec3(m_target_right + height).toIrrVector(); vertices[2].m_position = Vec3(m_target_left + height).toIrrVector();
vertices[3].Pos = Vec3(m_target_left + height).toIrrVector(); vertices[3].m_position = Vec3(m_target_right + height).toIrrVector();
for (unsigned int i = 0; i < 4; i++) 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, 255, 0, 0)
: video::SColor(128, 128, 128, 128); : video::SColor(128, 128, 128, 128);
} }
buffer->recalculateBoundingBox(); m_debug_target_dy_dc->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();
} }
#endif // DEBUG AND !SERVER_ONLY #endif // DEBUG AND !SERVER_ONLY
@ -114,6 +100,8 @@ CheckCannon::~CheckCannon()
#if defined(DEBUG) && !defined(SERVER_ONLY) #if defined(DEBUG) && !defined(SERVER_ONLY)
if(UserConfigParams::m_track_debug) if(UserConfigParams::m_track_debug)
delete m_show_curve; delete m_show_curve;
if (m_debug_target_dy_dc)
m_debug_target_dy_dc->removeFromSP();
#endif #endif
} // ~CheckCannon } // ~CheckCannon
@ -125,18 +113,13 @@ void CheckCannon::changeDebugColor(bool is_active)
#if defined(DEBUG) && !defined(SERVER_ONLY) #if defined(DEBUG) && !defined(SERVER_ONLY)
CheckLine::changeDebugColor(is_active); 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 color = is_active ? video::SColor(192, 255, 0, 0)
: video::SColor(192, 128, 128, 128); : 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 #endif
} // changeDebugColor } // changeDebugColor

View File

@ -29,6 +29,11 @@ class Ipo;
class ShowCurve; class ShowCurve;
class XMLNode; class XMLNode;
namespace SP
{
class SPDynamicDrawCall;
}
/** /**
* \brief Implements a simple checkline that will cause a kart to be * \brief Implements a simple checkline that will cause a kart to be
* shot to a specified point. * shot to a specified point.
@ -51,7 +56,7 @@ private:
ShowCurve* m_show_curve; ShowCurve* m_show_curve;
/** Used to display debug information about checklines. */ /** Used to display debug information about checklines. */
scene::ISceneNode *m_debug_target_node; std::shared_ptr<SP::SPDynamicDrawCall> m_debug_target_dy_dc;
#endif #endif
std::vector<Flyable*> m_all_flyables; std::vector<Flyable*> m_all_flyables;
std::vector<Vec3> m_flyable_previous_position; std::vector<Vec3> m_flyable_previous_position;

View File

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

View File

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