1
This commit is contained in:
parent
c87691e5bc
commit
a36c071f88
@ -19,6 +19,7 @@ include_directories(
|
|||||||
/usr/include/jsoncpp
|
/usr/include/jsoncpp
|
||||||
/usr/include/hiredis
|
/usr/include/hiredis
|
||||||
/usr/include/eigen3
|
/usr/include/eigen3
|
||||||
|
/usr/include/glm
|
||||||
../../third_party
|
../../third_party
|
||||||
.
|
.
|
||||||
)
|
)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "roommgr.h"
|
#include "roommgr.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
|
#include "collision.h"
|
||||||
|
|
||||||
#include "ss_msgid.pb.h"
|
#include "ss_msgid.pb.h"
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
@ -59,10 +60,11 @@ static void SavePerfLog()
|
|||||||
|
|
||||||
void App::Init(int argc, char* argv[])
|
void App::Init(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
#if 0
|
#if 1
|
||||||
{
|
{
|
||||||
Vector2D v1(1, 1);
|
Vector2D v1(1, 1);
|
||||||
Vector2D v2 = v1.Rotate(-0.25);
|
Vector2D v2 = v1.Rotate(-0.25);
|
||||||
|
TestGlm();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
#include <glm/gtx/intersect.hpp>
|
||||||
|
#include <glm/vec3.hpp>
|
||||||
|
|
||||||
|
void TestGlm()
|
||||||
|
{
|
||||||
|
glm::vec3 orig(0.0, 0.0, 0.0);
|
||||||
|
glm::vec3 dir(1.0, 1.0, 0);
|
||||||
|
glm::vec3 v0(0.0, 1.0, 0);
|
||||||
|
glm::vec3 v1(1.3, 1.0, 0);
|
||||||
|
glm::vec3 v2(0.0, 2.0, 0);
|
||||||
|
glm::vec3 baryPosition;
|
||||||
|
bool ret = glm::intersectRayTriangle(orig, dir, v0, v1, v2, baryPosition);
|
||||||
|
int i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool IntersectSegmentCircle(Vector2D p0, Vector2D p1, Vector2D pos, float rad)
|
bool IntersectSegmentCircle(Vector2D p0, Vector2D p1, Vector2D pos, float rad)
|
||||||
{
|
{
|
||||||
|
@ -5,3 +5,4 @@ bool IntersectSegmentAabb(Vector2D p0, Vector2D p1, Vector2D _min, Vector2D _max
|
|||||||
bool IntersectAabbCircle(Vector2D a_min, Vector2D a_max, Vector2D b_pos, float b_rad);
|
bool IntersectAabbCircle(Vector2D a_min, Vector2D a_max, Vector2D b_pos, float b_rad);
|
||||||
bool IntersectAabbAabb(Vector2D a_min, Vector2D a_max, Vector2D b_min, Vector2D b_max);
|
bool IntersectAabbAabb(Vector2D a_min, Vector2D a_max, Vector2D b_min, Vector2D b_max);
|
||||||
bool IntersectCircleCircle(Vector2D a_pos, float a_rad, Vector2D b_pos, float b_rad);
|
bool IntersectCircleCircle(Vector2D a_pos, float a_rad, Vector2D b_pos, float b_rad);
|
||||||
|
void TestGlm();
|
||||||
|
@ -138,12 +138,18 @@ bool Room::RandomPos(Human* hum, float distance, Vector2D& out_pos)
|
|||||||
collider.rad = hum->meta->i->radius();
|
collider.rad = hum->meta->i->radius();
|
||||||
|
|
||||||
for (auto& pair : uniid_hash_) {
|
for (auto& pair : uniid_hash_) {
|
||||||
|
if (pair.second->entity_type == ET_Player ||
|
||||||
|
pair.second->entity_type == ET_Bullet
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
for (auto& itr : pair.second->colliders) {
|
for (auto& itr : pair.second->colliders) {
|
||||||
if (collider.Intersect(itr)) {
|
if (collider.Intersect(itr)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
out_pos = hum->pos + collider.pos;
|
out_pos = hum->pos + collider.pos;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -180,7 +186,8 @@ void Room::CollisionDetection(Entity* sender, int detection_flags, std::vector<E
|
|||||||
if (sender->entity_type == ET_Bullet) {
|
if (sender->entity_type == ET_Bullet) {
|
||||||
Bullet* bullet = (Bullet*)sender;
|
Bullet* bullet = (Bullet*)sender;
|
||||||
Human* hum = (Human*)pair.second;
|
Human* hum = (Human*)pair.second;
|
||||||
if (hum->team_id == 0 || bullet->player->team_id != hum->team_id) {
|
if (hum != bullet->player &&
|
||||||
|
(hum->team_id == 0 || bullet->player->team_id != hum->team_id)) {
|
||||||
if (bullet->TestCollision(hum)) {
|
if (bullet->TestCollision(hum)) {
|
||||||
objects.push_back(hum);
|
objects.push_back(hum);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user