2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2015-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2024-03-30 08:56:32 +08:00
|
|
|
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-10-01 16:24:52 +08:00
|
|
|
https://axmolengine.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __PHYSICS_3D_VIEWER_H__
|
|
|
|
#define __PHYSICS_3D_VIEWER_H__
|
|
|
|
|
2023-06-11 13:08:08 +08:00
|
|
|
#include "math/Math.h"
|
2024-05-03 22:15:08 +08:00
|
|
|
#include "base/Object.h"
|
2023-06-11 13:08:08 +08:00
|
|
|
#include "base/Types.h"
|
|
|
|
#include "base/Config.h"
|
|
|
|
#include "renderer/CustomCommand.h"
|
2019-11-23 20:27:39 +08:00
|
|
|
#include "renderer/backend/ProgramState.h"
|
|
|
|
#include "renderer/backend/Types.h"
|
|
|
|
|
2024-03-30 08:56:32 +08:00
|
|
|
#if defined(AX_ENABLE_3D_PHYSICS)
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2022-07-16 10:43:05 +08:00
|
|
|
# if (AX_ENABLE_BULLET_INTEGRATION)
|
2021-12-25 10:04:45 +08:00
|
|
|
# include "bullet/LinearMath/btIDebugDraw.h"
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup _3d
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Renderer;
|
|
|
|
|
|
|
|
/** @brief Physics3DDebugDrawer: debug draw the physics object, used by Physics3DWorld */
|
|
|
|
class Physics3DDebugDrawer : public btIDebugDraw
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Physics3DDebugDrawer();
|
|
|
|
virtual ~Physics3DDebugDrawer();
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void draw(ax::Renderer* renderer);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
// override function
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color) override;
|
|
|
|
virtual void drawContactPoint(const btVector3& PointOnB,
|
|
|
|
const btVector3& normalOnB,
|
|
|
|
btScalar distance,
|
|
|
|
int lifeTime,
|
|
|
|
const btVector3& color) override;
|
|
|
|
virtual void reportErrorWarning(const char* warningString) override;
|
|
|
|
virtual void draw3dText(const btVector3& location, const char* textString) override;
|
|
|
|
virtual void setDebugMode(int debugMode) override;
|
|
|
|
virtual int getDebugMode() const override;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void init();
|
|
|
|
void onBeforeDraw();
|
|
|
|
void onAfterDraw();
|
|
|
|
|
|
|
|
protected:
|
2024-03-14 23:38:45 +08:00
|
|
|
std::vector<V3F_C4F> _buffer;
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::backend::UniformLocation _locMVP;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::BlendFunc _blendFunc = BlendFunc::DISABLE;
|
|
|
|
ax::CustomCommand _customCommand;
|
|
|
|
ax::backend::ProgramState* _programState = nullptr;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool _dirty = true;
|
|
|
|
int _debugMode = DBG_DrawWireframe | DBG_DrawConstraints | DBG_DrawConstraintLimits;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
private:
|
2021-12-25 10:04:45 +08:00
|
|
|
bool _oldDepthTestEnabled = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// end of 3d group
|
|
|
|
/// @}
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2022-07-16 10:43:05 +08:00
|
|
|
# endif // AX_ENABLE_BULLET_INTEGRATION
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2024-03-30 08:56:32 +08:00
|
|
|
#endif // defined(AX_ENABLE_3D_PHYSICS)
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#endif // __PHYSICS_3D_VIEWER_H__
|