size_t instead of int (cannot have negative number of players :)
cleanup some formatting (more readable)
This commit is contained in:
parent
4c2b43d4b6
commit
7bc571f819
@ -240,7 +240,7 @@ namespace spades {
|
||||
IImage* ChatWindow::imageForIndex( char index )
|
||||
{
|
||||
int real = index - 'a';
|
||||
if( real >= 0 && real < mKillImages.size() ) {
|
||||
if( real >= 0 && real < (int)mKillImages.size() ) {
|
||||
return mKillImages[real];
|
||||
}
|
||||
return NULL;
|
||||
|
@ -239,7 +239,7 @@ namespace spades {
|
||||
SPLog("World set");
|
||||
|
||||
clientPlayers.resize(world->GetNumPlayerSlots());
|
||||
for(int i = 0; i < world->GetNumPlayerSlots(); i++) {
|
||||
for(size_t i = 0; i < world->GetNumPlayerSlots(); i++) {
|
||||
Player *p = world->GetPlayer(i);
|
||||
if(p){
|
||||
clientPlayers[i] = new ClientPlayer(p, this);
|
||||
@ -1738,8 +1738,7 @@ namespace spades {
|
||||
renderer->RenderModel(model, param);
|
||||
}
|
||||
|
||||
void Client::AddDebugObjectToScene(const spades::OBB3 &obb,
|
||||
const Vector4& color) {
|
||||
void Client::AddDebugObjectToScene(const spades::OBB3 &obb, const Vector4& color) {
|
||||
const Matrix4& mat = obb.m;
|
||||
Vector3 v[2][2][2];
|
||||
v[0][0][0] = (mat * MakeVector3(0,0,0)).GetXYZ();
|
||||
@ -1878,7 +1877,7 @@ namespace spades {
|
||||
if(world){
|
||||
Player *p = world->GetLocalPlayer();
|
||||
|
||||
for(int i = 0; i < world->GetNumPlayerSlots(); i++)
|
||||
for(size_t i = 0; i < world->GetNumPlayerSlots(); i++)
|
||||
if(world->GetPlayer(i)){
|
||||
SPAssert(clientPlayers[i]);
|
||||
clientPlayers[i]->AddToScene();
|
||||
|
@ -403,9 +403,7 @@ namespace spades {
|
||||
|
||||
// add glare
|
||||
renderer->SetColor(MakeVector4(1, .7f, .5f, 0) * brightness * .3f);
|
||||
renderer->AddSprite(renderer->RegisterImage("Gfx/Glare.tga"),
|
||||
(eyeMatrix * MakeVector3(0, 0.3f, -0.3f)).GetXYZ(),
|
||||
.8f, 0.f);
|
||||
renderer->AddSprite(renderer->RegisterImage("Gfx/Glare.tga"), (eyeMatrix * MakeVector3(0, 0.3f, -0.3f)).GetXYZ(), .8f, 0.f);
|
||||
}
|
||||
|
||||
Vector3 leftHand, rightHand;
|
||||
@ -483,9 +481,7 @@ namespace spades {
|
||||
IModel *model2 = renderer->RegisterModel("Models/Player/UpperArm.kv6");
|
||||
|
||||
IntVector3 col = p->GetColor();
|
||||
param.customColor = MakeVector3(col.x/255.f,
|
||||
col.y/255.f,
|
||||
col.z/255.f);
|
||||
param.customColor = MakeVector3(col.x/255.f, col.y/255.f, col.z/255.f);
|
||||
|
||||
const float armlen = 0.5f;
|
||||
|
||||
@ -519,10 +515,7 @@ namespace spades {
|
||||
axises[0] = Vector3::Cross(axises[1], axises[2]).Normalize();
|
||||
|
||||
Matrix4 mat = Matrix4::Scale(.05f);
|
||||
mat = Matrix4::FromAxis(axises[0],
|
||||
axises[1],
|
||||
axises[2],
|
||||
elbow) * mat;
|
||||
mat = Matrix4::FromAxis(axises[0], axises[1], axises[2], elbow) * mat;
|
||||
mat = eyeMatrix * mat;
|
||||
|
||||
param.matrix = mat;
|
||||
@ -537,10 +530,7 @@ namespace spades {
|
||||
axises[0] = Vector3::Cross(axises[1], axises[2]).Normalize();
|
||||
|
||||
Matrix4 mat = Matrix4::Scale(.05f);
|
||||
mat = Matrix4::FromAxis(axises[0],
|
||||
axises[1],
|
||||
axises[2],
|
||||
shoulder) * mat;
|
||||
mat = Matrix4::FromAxis(axises[0], axises[1], axises[2], shoulder) * mat;
|
||||
mat = eyeMatrix * mat;
|
||||
|
||||
param.matrix = mat;
|
||||
@ -566,13 +556,10 @@ namespace spades {
|
||||
if(!p->IsAlive()){
|
||||
if(!cg_ragdoll){
|
||||
ModelRenderParam param;
|
||||
param.matrix = Matrix4::Translate(p->GetOrigin()+
|
||||
MakeVector3(0,0,1));
|
||||
param.matrix = Matrix4::Translate(p->GetOrigin()+ MakeVector3(0,0,1));
|
||||
param.matrix = param.matrix * Matrix4::Scale(.1f);
|
||||
IntVector3 col = p->GetColor();
|
||||
param.customColor = MakeVector3(col.x/255.f,
|
||||
col.y/255.f,
|
||||
col.z/255.f);
|
||||
param.customColor = MakeVector3(col.x/255.f, col.y/255.f, col.z/255.f);
|
||||
|
||||
IModel *model = renderer->RegisterModel("Models/Player/Dead.kv6");
|
||||
renderer->RenderModel(model, param);
|
||||
@ -609,17 +596,14 @@ namespace spades {
|
||||
IModel *model;
|
||||
Vector3 front = p->GetFront();
|
||||
IntVector3 col = p->GetColor();
|
||||
param.customColor = MakeVector3(col.x/255.f,
|
||||
col.y/255.f,
|
||||
col.z/255.f);
|
||||
param.customColor = MakeVector3(col.x/255.f, col.y/255.f, col.z/255.f);
|
||||
|
||||
float yaw = atan2(front.y, front.x) + M_PI * .5f;
|
||||
float pitch = -atan2(front.z, sqrt(front.x * front.x + front.y * front.y));
|
||||
|
||||
// lower axis
|
||||
Matrix4 lower = Matrix4::Translate(p->GetOrigin());
|
||||
lower = lower * Matrix4::Rotate(MakeVector3(0,0,1),
|
||||
yaw);
|
||||
lower = lower * Matrix4::Rotate(MakeVector3(0,0,1), yaw);
|
||||
|
||||
Matrix4 scaler = Matrix4::Scale(0.1f);
|
||||
scaler = scaler * Matrix4::Scale(-1,-1,1);
|
||||
@ -634,16 +618,12 @@ namespace spades {
|
||||
|
||||
float ang = sinf(p->GetWalkAnimationProgress() * M_PI * 2.f) * 0.6f;
|
||||
float walkVel = Vector3::Dot(p->GetVelocty(), p->GetFront2D()) * 4.f;
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
-ang * walkVel);
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(1,0,0), ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(1,0,0), -ang * walkVel);
|
||||
|
||||
walkVel = Vector3::Dot(p->GetVelocty(), p->GetRight()) * 3.f;
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(0,1,0),
|
||||
ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(0,1,0),
|
||||
-ang * walkVel);
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(0,1,0), ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(0,1,0), -ang * walkVel);
|
||||
|
||||
leg1 = lower * leg1;
|
||||
leg2 = lower * leg2;
|
||||
@ -672,16 +652,12 @@ namespace spades {
|
||||
|
||||
float ang = sinf(p->GetWalkAnimationProgress() * M_PI * 2.f) * 0.6f;
|
||||
float walkVel = Vector3::Dot(p->GetVelocty(), p->GetFront2D()) * 4.f;
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
-ang * walkVel);
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(1,0,0), ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(1,0,0), -ang * walkVel);
|
||||
|
||||
walkVel = Vector3::Dot(p->GetVelocty(), p->GetRight()) * 3.f;
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(0,1,0),
|
||||
ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(0,1,0),
|
||||
-ang * walkVel);
|
||||
leg1 = leg1 * Matrix4::Rotate(MakeVector3(0,1,0), ang * walkVel);
|
||||
leg2 = leg2 * Matrix4::Rotate(MakeVector3(0,1,0), -ang * walkVel);
|
||||
|
||||
leg1 = lower * leg1;
|
||||
leg2 = lower * leg2;
|
||||
@ -716,16 +692,14 @@ namespace spades {
|
||||
armPitch *= .9f;
|
||||
}
|
||||
|
||||
arms = arms * Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
armPitch);
|
||||
arms = arms * Matrix4::Rotate(MakeVector3(1,0,0), armPitch);
|
||||
|
||||
model = renderer->RegisterModel("Models/Player/Arms.kv6");
|
||||
param.matrix = arms * scaler;
|
||||
renderer->RenderModel(model, param);
|
||||
|
||||
|
||||
head = head * Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
pitch);
|
||||
head = head * Matrix4::Rotate(MakeVector3(1,0,0), pitch);
|
||||
|
||||
model = renderer->RegisterModel("Models/Player/Head.kv6");
|
||||
param.matrix = head * scaler;
|
||||
@ -751,18 +725,14 @@ namespace spades {
|
||||
if(team.hasIntel && team.carrier == p->GetId()){
|
||||
|
||||
IntVector3 col2 = world->GetTeam(1-p->GetTeamId()).color;
|
||||
param.customColor = MakeVector3(col2.x/255.f,
|
||||
col2.y/255.f,
|
||||
col2.z/255.f);
|
||||
param.customColor = MakeVector3(col2.x/255.f, col2.y/255.f, col2.z/255.f);
|
||||
Matrix4 mIntel = torso * Matrix4::Translate(0,0.6f,0.5f);
|
||||
|
||||
model = renderer->RegisterModel("Models/MapObjects/Intel.kv6");
|
||||
param.matrix = mIntel * scaler;
|
||||
renderer->RenderModel(model, param);
|
||||
|
||||
param.customColor = MakeVector3(col.x/255.f,
|
||||
col.y/255.f,
|
||||
col.z/255.f);
|
||||
param.customColor = MakeVector3(col.x/255.f, col.y/255.f, col.z/255.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -787,9 +757,7 @@ namespace spades {
|
||||
if(false){
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/Ball.png");
|
||||
renderer->SetColor(MakeVector4(1, 0, 0, 0));
|
||||
renderer->AddLongSprite(img, lastSceneDef.viewOrigin +
|
||||
MakeVector3(0, 0, 1),
|
||||
p->GetOrigin(), 0.5f);
|
||||
renderer->AddLongSprite(img, lastSceneDef.viewOrigin + MakeVector3(0, 0, 1), p->GetOrigin(), 0.5f);
|
||||
}
|
||||
|
||||
float distancePowered = (p->GetOrigin() - lastSceneDef.viewOrigin).GetPoweredLength();
|
||||
|
@ -846,13 +846,7 @@ namespace spades {
|
||||
Vector3 Player::GetOrigin() {
|
||||
SPADES_MARK_FUNCTION_DEBUG();
|
||||
Vector3 v = eye;
|
||||
float offset;
|
||||
if(input.crouch){
|
||||
offset = .45f;
|
||||
}else{
|
||||
offset = .9f;
|
||||
}
|
||||
v.z += offset;
|
||||
v.z += (input.crouch ? .45f : .9f);
|
||||
v.z += .3f;
|
||||
return v;
|
||||
}
|
||||
@ -1202,7 +1196,8 @@ namespace spades {
|
||||
(float)(moveSteps & 1) * .5f;
|
||||
}
|
||||
|
||||
Player::HitBoxes Player::GetHitBoxes() {
|
||||
Player::HitBoxes Player::GetHitBoxes()
|
||||
{
|
||||
SPADES_MARK_FUNCTION_DEBUG();
|
||||
Player::HitBoxes hb;
|
||||
|
||||
@ -1213,68 +1208,55 @@ namespace spades {
|
||||
|
||||
// lower axis
|
||||
Matrix4 lower = Matrix4::Translate(GetOrigin());
|
||||
lower = lower * Matrix4::Rotate(MakeVector3(0,0,1),
|
||||
yaw);
|
||||
lower = lower * Matrix4::Rotate(MakeVector3(0,0,1), yaw);
|
||||
|
||||
Matrix4 torso;
|
||||
|
||||
if(input.crouch){
|
||||
lower = lower * Matrix4::Translate(0, 0, -0.4f);
|
||||
// lower
|
||||
hb.limbs[0] = AABB3(-.4f, -.15f, 0.5f,
|
||||
0.3f, .3f, 0.5f);
|
||||
hb.limbs[0] = AABB3(-.4f, -.15f, 0.5f, 0.3f, .3f, 0.5f);
|
||||
hb.limbs[0] = lower * hb.limbs[0];
|
||||
|
||||
hb.limbs[1] = AABB3(.1f, -.15f, 0.5f,
|
||||
0.3f, .3f, 0.5f);
|
||||
hb.limbs[1] = AABB3(.1f, -.15f, 0.5f, 0.3f, .3f, 0.5f);
|
||||
hb.limbs[1] = lower * hb.limbs[1];
|
||||
|
||||
torso = lower * Matrix4::Translate(0, 0, -0.3f);
|
||||
|
||||
// torso
|
||||
hb.torso = AABB3(-.4f, -.15f, 0.1f,
|
||||
.8f, .8f, .6f);
|
||||
hb.torso = AABB3(-.4f, -.15f, 0.1f, .8f, .8f, .6f);
|
||||
hb.torso = torso * hb.torso;
|
||||
|
||||
hb.limbs[2] = AABB3(-.6f, -.15f, 0.1f,
|
||||
1.2f, .3f, .6f);
|
||||
hb.limbs[2] = AABB3(-.6f, -.15f, 0.1f, 1.2f, .3f, .6f);
|
||||
hb.limbs[2] = torso * hb.limbs[2];
|
||||
|
||||
// head
|
||||
hb.head = AABB3(-.3f, -.3f, -0.45f,
|
||||
.6f, .6f, 0.6f);
|
||||
hb.head = AABB3(-.3f, -.3f, -0.45f, .6f, .6f, 0.6f);
|
||||
hb.head = Matrix4::Translate(0, 0, -0.15f) * hb.head;
|
||||
hb.head = Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
pitch) * hb.head;
|
||||
hb.head = Matrix4::Rotate(MakeVector3(1,0,0), pitch) * hb.head;
|
||||
hb.head = Matrix4::Translate(0, 0, 0.15f) * hb.head;
|
||||
hb.head = torso * hb.head;
|
||||
}else{
|
||||
// lower
|
||||
hb.limbs[0] = AABB3(-.4f, -.15f, 0.f,
|
||||
0.3f, .3f, 1.f);
|
||||
hb.limbs[0] = AABB3(-.4f, -.15f, 0.f, 0.3f, .3f, 1.f);
|
||||
hb.limbs[0] = lower * hb.limbs[0];
|
||||
|
||||
hb.limbs[1] = AABB3(.1f, -.15f, 0.f,
|
||||
0.3f, .3f, 1.f);
|
||||
hb.limbs[1] = AABB3(.1f, -.15f, 0.f, 0.3f, .3f, 1.f);
|
||||
hb.limbs[1] = lower * hb.limbs[1];
|
||||
|
||||
torso = lower * Matrix4::Translate(0, 0, -1.1f);
|
||||
|
||||
// torso
|
||||
hb.torso = AABB3(-.4f, -.15f, 0.1f,
|
||||
.8f, .3f, .9f);
|
||||
hb.torso = AABB3(-.4f, -.15f, 0.1f, .8f, .3f, .9f);
|
||||
hb.torso = torso * hb.torso;
|
||||
|
||||
hb.limbs[2] = AABB3(-.6f, -.15f, 0.1f,
|
||||
1.2f, .3f, .9f);
|
||||
hb.limbs[2] = AABB3(-.6f, -.15f, 0.1f, 1.2f, .3f, .9f);
|
||||
hb.limbs[2] = torso * hb.limbs[2];
|
||||
|
||||
// head
|
||||
hb.head = AABB3(-.3f, -.3f, -0.5f,
|
||||
.6f, .6f, 0.6f);
|
||||
hb.head = AABB3(-.3f, -.3f, -0.5f, .6f, .6f, 0.6f);
|
||||
hb.head = Matrix4::Translate(0, 0, -0.1f) * hb.head;
|
||||
hb.head = Matrix4::Rotate(MakeVector3(1,0,0),
|
||||
pitch) * hb.head;
|
||||
hb.head = Matrix4::Rotate(MakeVector3(1,0,0), pitch) * hb.head;
|
||||
hb.head = Matrix4::Translate(0, 0, 0.1f) * hb.head;
|
||||
hb.head = torso * hb.head;
|
||||
}
|
||||
|
@ -82,12 +82,10 @@ namespace spades {
|
||||
void AddGrenade(Grenade *);
|
||||
std::vector<Grenade *> GetAllGrenades();
|
||||
|
||||
std::vector<IntVector3> CubeLine(IntVector3 v1,
|
||||
IntVector3 v2,
|
||||
int maxLength);
|
||||
std::vector<IntVector3> CubeLine(IntVector3 v1, IntVector3 v2, int maxLength);
|
||||
|
||||
Player *GetPlayer(unsigned int i){
|
||||
SPAssert(i >= 0);
|
||||
//SPAssert(i >= 0); lm: unsigned cannot be smaller than 0 :)
|
||||
SPAssert(i < players.size());
|
||||
return players[i];
|
||||
}
|
||||
@ -119,8 +117,8 @@ namespace spades {
|
||||
|
||||
WeaponRayCastResult WeaponRayCast(Vector3 startPos, Vector3 dir, Player *exclude);
|
||||
|
||||
int GetNumPlayerSlots() {
|
||||
return (int)players.size();
|
||||
size_t GetNumPlayerSlots() {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
int GetLocalPlayerIndex() {
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include <vector>
|
||||
#include <math.h>
|
||||
//#include "../Core/Debug.h"
|
||||
#include <string>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -490,17 +490,14 @@ namespace spades {
|
||||
lights.push_back(GLDynamicLight(light));
|
||||
}
|
||||
|
||||
void GLRenderer::AddDebugLine(spades::Vector3 a,
|
||||
spades::Vector3 b,
|
||||
spades::Vector4 color) {
|
||||
void GLRenderer::AddDebugLine(spades::Vector3 a, spades::Vector3 b, spades::Vector4 color)
|
||||
{
|
||||
DebugLine line = {a, b, color};
|
||||
debugLines.push_back(line);
|
||||
}
|
||||
|
||||
void GLRenderer::AddSprite(client::IImage *img,
|
||||
spades::Vector3 center,
|
||||
float radius,
|
||||
float rotation){
|
||||
void GLRenderer::AddSprite(client::IImage *img, spades::Vector3 center, float radius, float rotation)
|
||||
{
|
||||
SPADES_MARK_FUNCTION_DEBUG();
|
||||
GLImage *im = dynamic_cast<GLImage *>(img);
|
||||
if(!im)
|
||||
@ -509,8 +506,7 @@ namespace spades {
|
||||
if(!SphereFrustrumCull(center, radius * 1.5f))
|
||||
return;
|
||||
|
||||
spriteRenderer->Add(im, center, radius, rotation,
|
||||
drawColor);
|
||||
spriteRenderer->Add(im, center, radius, rotation, drawColor);
|
||||
}
|
||||
|
||||
void GLRenderer::AddLongSprite(client::IImage *img,
|
||||
@ -561,14 +557,8 @@ namespace spades {
|
||||
positionAttribute(program);
|
||||
colorAttribute(program);
|
||||
|
||||
device->VertexAttribPointer(positionAttribute(),
|
||||
3, IGLDevice::FloatType,
|
||||
false, sizeof(DebugLineVertex),
|
||||
vertices.data());
|
||||
device->VertexAttribPointer(colorAttribute(),
|
||||
4, IGLDevice::FloatType,
|
||||
false, sizeof(DebugLineVertex),
|
||||
(const char*)vertices.data() + sizeof(float) * 3);
|
||||
device->VertexAttribPointer(positionAttribute(), 3, IGLDevice::FloatType, false, sizeof(DebugLineVertex), vertices.data());
|
||||
device->VertexAttribPointer(colorAttribute(), 4, IGLDevice::FloatType, false, sizeof(DebugLineVertex), (const char*)vertices.data() + sizeof(float) * 3);
|
||||
|
||||
device->EnableVertexAttribArray(positionAttribute(), true);
|
||||
device->EnableVertexAttribArray(colorAttribute(), true);
|
||||
@ -613,8 +603,7 @@ namespace spades {
|
||||
device->Enable(IGLDevice::Blend, true);
|
||||
device->Enable(IGLDevice::DepthTest, true);
|
||||
device->DepthFunc(IGLDevice::Equal);
|
||||
device->BlendFunc(IGLDevice::SrcAlpha,
|
||||
IGLDevice::One);
|
||||
device->BlendFunc(IGLDevice::SrcAlpha, IGLDevice::One);
|
||||
|
||||
if(!sceneDef.skipWorld && mapRenderer){
|
||||
mapRenderer->RenderDynamicLightPass(lights);
|
||||
|
@ -202,8 +202,7 @@ namespace spades {
|
||||
}
|
||||
|
||||
bool BoxFrustrumCull(const AABB3&);
|
||||
bool SphereFrustrumCull(const Vector3& center,
|
||||
float radius);
|
||||
bool SphereFrustrumCull(const Vector3& center, float radius);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user