This commit is contained in:
aozhiwei 2023-02-10 11:07:24 +08:00
parent 640e2ebaaf
commit a2df9aafb2
4 changed files with 35 additions and 19 deletions

View File

@ -80,23 +80,6 @@ void Bullet::Initialize()
hit_pos,
glm::vec3(10, 10, 10),
room->AllocUniid());
#if 1
auto transform =
glm::rotate(
glm::mat4(1.0),
glm::radians(45.0f),
//glm::radians(angle),
glm::vec3(0.0f, 1.0f, 0.0f)
);
#else
glm::mat4 transform = glm::eulerAngleYXZ(dir1.y, dir1.x, dir1.z);
#endif
glm::quat q = glm::toQuat(transform);
DebugCmd::CreateCube(sender.Get(),
GetPos().ToGlmVec3(),
glm::vec3(10, 10, 10),
q,
room->AllocUniid());
}
}
#endif

View File

@ -63,6 +63,28 @@ void DebugCmd::CreateCube(Creature* c,
}
}
void DebugCmd::DrawLine(Creature* c,
const glm::vec3& begin,
const glm::vec3& end,
float time)
{
if (c->IsPlayer() && Enable()) {
cs::SMDebugCmd msg;
msg.set_cmd("draw_line");
msg.add_params(begin.x);
msg.add_params(begin.y);
msg.add_params(begin.z);
msg.add_params(end.x);
msg.add_params(end.y);
msg.add_params(end.z);
msg.add_params(time);
c->AsPlayer()->SendNotifyMsg(msg);
}
}
void DebugCmd::DestoryGameObject(Creature* c, int uniid)
{
if (c->IsPlayer() && Enable()) {

View File

@ -23,6 +23,11 @@ class DebugCmd
const glm::quat& rotation,
int uniid);
static void DrawLine(Creature* c,
const glm::vec3& begin,
const glm::vec3& end,
float time);
static void DestoryGameObject(Creature* c, int uniid);
};

View File

@ -19,6 +19,7 @@
#include "entityfactory.h"
#include "creature.h"
#include "glmhelper.h"
#include "debugcmd.h"
#include "mt/MetaMgr.h"
#include "mt/Param.h"
@ -931,7 +932,7 @@ bool MapInstance::SceneRaycast(const glm::vec3& orig,
);
node->tri->check_flag = raycast_index;
++tri_count;
if (hit) {
if (hit && distance > 0.00001f) {
if (nearest_node) {
if (distance < nearest_distance) {
nearest_node = node;
@ -957,7 +958,12 @@ bool MapInstance::SceneRaycast(const glm::vec3& orig,
if (result) {
#ifdef DEBUG
a8::XPrintf("nearest_node:%s tri_count:%d\n", {nearest_node->tri->node->name, tri_count});
if (DebugCmd::Enable()) {
a8::XPrintf("nearest_node:%s tri_count:%d nearest_distance:%f\n",
{nearest_node->tri->node->name,
tri_count,
nearest_distance});
}
#endif
hit_pos = nearest_pt;
ray_length = nearest_distance;