From 1de1cdf53082a1ca10f741c8e5512c90f29e9e41 Mon Sep 17 00:00:00 2001 From: Benau Date: Wed, 3 Jan 2018 15:28:29 +0800 Subject: [PATCH] Port line debug to SP, removing all unicolor code too --- src/karts/controller/skidding_ai.cpp | 3 - src/karts/controller/test_ai.cpp | 3 - src/tracks/check_cannon.cpp | 59 +++++++------------ src/tracks/check_cannon.hpp | 9 ++- src/tracks/check_line.cpp | 84 ++++++++++------------------ src/tracks/check_line.hpp | 8 ++- src/tracks/track.cpp | 12 ---- 7 files changed, 65 insertions(+), 113 deletions(-) diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index c3ee4fafa..957934f2f 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -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)); diff --git a/src/karts/controller/test_ai.cpp b/src/karts/controller/test_ai.cpp index 95313d8a8..e7fc11f07 100644 --- a/src/karts/controller/test_ai.cpp +++ b/src/karts/controller/test_ai.cpp @@ -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)); diff --git a/src/tracks/check_cannon.cpp b/src/tracks/check_cannon.cpp index 211b4b1e7..277f970ea 100644 --- a/src/tracks/check_cannon.cpp +++ b/src/tracks/check_cannon.cpp @@ -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 + (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 diff --git a/src/tracks/check_cannon.hpp b/src/tracks/check_cannon.hpp index 42358bb43..da44b5c93 100644 --- a/src/tracks/check_cannon.hpp +++ b/src/tracks/check_cannon.hpp @@ -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 m_debug_target_dy_dc; #endif std::vector m_all_flyables; std::vector m_flyable_previous_position; diff --git a/src/tracks/check_line.cpp b/src/tracks/check_line.cpp index 403abc334..293e0e077 100644 --- a/src/tracks/check_line.cpp +++ b/src/tracks/check_line.cpp @@ -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 + (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 // ---------------------------------------------------------------------------- diff --git a/src/tracks/check_line.hpp b/src/tracks/check_line.hpp index 84e3c3cd7..c9f44e973 100644 --- a/src/tracks/check_line.hpp +++ b/src/tracks/check_line.hpp @@ -22,6 +22,7 @@ #include #include #include +#include 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 m_previous_sign; /** Used to display debug information about checklines. */ - scene::ISceneNode *m_debug_node; + std::shared_ptr 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. */ diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 1e9e15a8e..5d7b04431 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -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]);