Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulletEngine #579

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7dde0f5
added bulletengine-skeleton
Apr 5, 2014
84fe57d
intermediate
Apr 5, 2014
fd9e8c7
stripped projectile of WorldObject inheritance
Apr 5, 2014
04cdfaa
Merge branch 'master' of github.com:voxelinc/voxellancer into bullete…
Apr 5, 2014
0eba1e9
move Bullet::passiveForCollisionDetection to WorldObjectBullet
Apr 5, 2014
5d6da02
mv genericbullet.* -> genericworldobjectbullet.*
Apr 5, 2014
39856fb
WorldObjectBuilder -> WorldElementBuilder
Apr 5, 2014
32feb48
Make WorldElementBuilder decide based on .ini whether a bullet is ins…
Apr 5, 2014
d559196
intermediate
Apr 5, 2014
b351273
Established skeleton pipeline for rendering InstancedBullets via Inst…
Apr 5, 2014
03ef757
intermediate
Apr 5, 2014
c97abd7
intermediate
Apr 6, 2014
9f24f02
intermediate
Apr 6, 2014
e521280
intermediate on bulletengine
Apr 6, 2014
830a586
something related to bulletengine
Apr 6, 2014
1008a70
merge with master
Apr 8, 2014
9275ac1
implemented instancedbullet
Apr 8, 2014
d453d67
continue bulletengine
Apr 9, 2014
7c78172
merge with origin
Apr 9, 2014
671d34a
intermediate
Apr 10, 2014
0436069
initial somehow working version of bulletengine
Apr 10, 2014
5fe8c51
Merge branch 'handle_improvements' of github.com:voxelinc/voxellancer…
Apr 10, 2014
0c58138
bulletengine working without collision and continuous rotation
Apr 10, 2014
fd860a2
Merge branch 'worldtreenoderef' of github.com:voxelinc/voxellancer in…
Apr 10, 2014
57b2e2e
bulletengine continues
Apr 10, 2014
2775f4b
bulletengine improvements
Apr 11, 2014
75a7a90
continue bulletengine
Apr 11, 2014
cb7746d
BulletEngine: Better removal strategy of InstancedBullets
Apr 11, 2014
bf2e214
continue bulletengine
Apr 11, 2014
adf8449
Fixed crah on contextreplace
Apr 11, 2014
dc572e8
enable hitSound and emissiveness on instancedbullets
Apr 12, 2014
bfd7c96
add docu to bulletengine/
Apr 12, 2014
5f68045
merge with master
Apr 13, 2014
7293f7d
fix Windows compile
gersseba Apr 17, 2014
203ea81
compiling again
Apr 19, 2014
f5d9bdf
add drawable
Apr 19, 2014
a4f1bc4
Merge branch 'bulletengine' of github.com:voxelinc/voxellancer into b…
Apr 19, 2014
22c3c10
trying to fix it
Apr 19, 2014
68f8e14
bulletengine working again. glowsquad, you better not cross my path t…
Apr 19, 2014
6a41261
remove drawable again
Apr 19, 2014
1639a8a
merge with master
May 11, 2014
eeaf6a9
Splitrockets also split if target is dead; Bullet::extent
May 11, 2014
832d9eb
remove outcommented logging
May 11, 2014
5a250cf
replaced voxelparticleengine::time with UWT ;)
May 18, 2014
b5e6552
merge with master
May 31, 2014
825025a
Renamed WorldElementBuilder to VoxelObjectBuilder
May 31, 2014
68ac315
merge with master
Jun 6, 2014
eb070fd
add virtual to VoxelParticleEngine-destructor decl.
Jun 8, 2014
472f591
Merge branch 'master' of github.com:voxelinc/voxellancer into bullete…
Aug 18, 2014
bb21df7
fixed indentation in src/geometry/line.inl
Aug 18, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data/equipment/projectiles/gunbullet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[general]
type=bullet
voxelcluster=gunbullet.csv
instanced=true
lifetime=1.5
speed=350.0
spinning=10.0
Expand All @@ -9,4 +10,4 @@ emissiveness=0.4
collisionFieldOfDamage=7.2

[hitsound]
name=data/sound/hit2.ogg
name=data/sound/hit2.ogg
3 changes: 2 additions & 1 deletion data/equipment/projectiles/hornet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[general]
type=rocket
voxelcluster=hornet.csv
instanced=false
lifetime=60
scale=0.5
collisionFieldOfDamage=inf
Expand All @@ -11,4 +12,4 @@ direction=0.0,0.0,1.0

[explosionsound]
name=data/sound/102733__sarge4267__explosion3.ogg
attenuation=0.3
attenuation=0.3
3 changes: 2 additions & 1 deletion data/equipment/projectiles/ionbullet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[general]
type=bullet
voxelcluster=ionbullet.csv
instanced=true
lifetime=10
speed=1000.0
spinning=1000.0
Expand All @@ -9,4 +10,4 @@ emissiveness=1.0
collisionFieldOfDamage=inf

[hitsound]
name=data/sound/hit2.ogg
name=data/sound/hit2.ogg
3 changes: 2 additions & 1 deletion data/equipment/projectiles/pulselaser_bullet.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[general]
type=bullet
instanced=true
voxelcluster=pulselaser_bullet.csv
lifetime=1
speed=500.0
spinning=0.0
scale=0.4
emissiveness=0.4
emissiveness=40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik emissiveness should be 0.0 - 1.0, has something changed?

collisionFieldOfDamage=7.2

[hitsound]
Expand Down
3 changes: 2 additions & 1 deletion data/equipment/projectiles/railgunbullet.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[general]
type=bullet
voxelcluster=railgunbullet.csv
instanced=true
lifetime=1.5
speed=350.0
spinning=10.0
Expand All @@ -10,4 +11,4 @@ collisionFieldOfDamage=7.2

[hitsound]
name=data/sound/hit2.ogg
volume=0.5
volume=0.5
1 change: 1 addition & 0 deletions data/equipment/projectiles/snowball.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[general]
type=bullet
voxelcluster=snowball.csv
instanced=true
lifetime=2
speed=100.0
spinning=10.0
Expand Down
31 changes: 31 additions & 0 deletions data/shader/bulletengine/bullet.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#version 330

uniform float time;
uniform float withBorder;

layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 normalz;
layout(location = 2) out vec4 emissiveness;

in vec4 f_color;
flat in vec3 f_normal;
in float f_emissiveness;
in vec3 f_modelposition;
flat in float f_active;
flat in float f_deathTime;

vec4 voxelFragmentColor(vec3 color, float emissiveness, vec3 normal, vec3 positionInVoxel);
vec4 voxelFragmentEmissiveness(vec3 color, float emissiveness);
vec4 voxelFragmenNormalZ(vec3 normal);


void main() {
if (f_active < 0.5 || f_deathTime <= time) {
discard;
}

fragColor = voxelFragmentColor(f_color.xyz, f_emissiveness, f_normal, f_modelposition);
emissiveness = voxelFragmentEmissiveness(f_color.xyz, f_emissiveness);
normalz = voxelFragmenNormalZ(f_normal);
}

57 changes: 57 additions & 0 deletions data/shader/bulletengine/bullet.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#version 330

// Input
layout(location = 0) in vec3 v_vertex;
layout(location = 1) in vec3 v_normal;

layout(location = 2) in vec3 v_gridCell;
layout(location = 3) in vec4 v_color;
layout(location = 4) in float v_emissiveness;

layout(location = 5) in vec3 v_originPosition;
layout(location = 6) in vec3 v_originEulers;
layout(location = 7) in vec3 v_directionalSpeed;
layout(location = 8) in vec3 v_angularSpeed;
layout(location = 9) in vec3 v_center;
layout(location = 10) in float v_originTime;
layout(location = 11) in float v_deathTime;
layout(location = 12) in float v_active;


// Output
out vec4 f_color;
flat out vec3 f_normal;
out float f_emissiveness;
out vec3 f_modelposition;
flat out float f_active;
flat out float f_deathTime;

// Uniforms
uniform mat4 viewProjection;
uniform float time;
uniform float scale;
uniform float emissiveness;


vec3 qtransform(vec4 q, vec3 v);
vec4 quat(vec3 euler);

void main() {
f_active = v_active;
f_deathTime = v_deathTime;

float deltaTime = time - v_originTime;

f_color = v_color;
f_normal = v_normal;
f_emissiveness = clamp(emissiveness + v_emissiveness, 0, 1);
f_modelposition = v_vertex;

vec3 bulletEulers = v_originEulers + v_angularSpeed * deltaTime * 0.01;
vec4 bulletOrientation = quat(bulletEulers);

vec3 bulletPosition = v_originPosition + v_directionalSpeed * deltaTime;

gl_Position = viewProjection * vec4(qtransform(bulletOrientation, v_vertex + v_gridCell - v_center) * scale + bulletPosition, 1.0f);
}

2 changes: 1 addition & 1 deletion data/worldobjects/banner.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[general]
type=worldobject
type=other
voxelcluster=banner.csv
2 changes: 1 addition & 1 deletion data/worldobjects/cake.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[general]
type=worldobject
type=other
voxelcluster=cake.csv
scale=3

Expand Down
2 changes: 1 addition & 1 deletion data/worldobjects/idareyou.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[general]
type=worldobject
type=other
voxelcluster=idareyou.csv
2 changes: 1 addition & 1 deletion data/worldobjects/missionstart.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[general]
type=worldobject
type=other
voxelcluster=missionstart.csv
2 changes: 1 addition & 1 deletion lib/glow
9 changes: 1 addition & 8 deletions src/ai/aitask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@


AiTask::AiTask(BoardComputer* boardComputer):
m_handle(Handle<AiTask>(this)),
m_boardComputer(boardComputer)
{
}

AiTask::~AiTask() {
m_handle.invalidate();
}
AiTask::~AiTask() = default;

BoardComputer* AiTask::boardComputer() {
return m_boardComputer;
Expand All @@ -19,7 +16,3 @@ bool AiTask::isFinished() {
return false;
}

Handle<AiTask>& AiTask::handle() {
return m_handle;
}

6 changes: 2 additions & 4 deletions src/ai/aitask.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "scripting/scriptable.h"

#include "utils/handle/handle.h"
#include "utils/handle/handleowner.h"


class BoardComputer;
Expand All @@ -12,7 +13,7 @@ class WorldObject;
* Basic unit for AI. A Ship's Character can always execute only one task.
*/

class AiTask : public Scriptable {
class AiTask : public Scriptable, public HandleOwner {
public:
AiTask(BoardComputer* boardComputer);
virtual ~AiTask();
Expand All @@ -22,11 +23,8 @@ class AiTask : public Scriptable {
virtual void update(float deltaSec) = 0;
virtual bool isFinished();

Handle<AiTask>& handle();


protected:
Handle<AiTask> m_handle;
BoardComputer* m_boardComputer;
};

6 changes: 3 additions & 3 deletions src/ai/basictasks/cruiserfighttask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void CruiserFightTask::update(float deltaSec) {
}

if (targetDistance() < m_maxRocketDistance) {
boardComputer()->shootRockets(m_primaryTarget->handle());
boardComputer()->shootRockets(m_primaryTarget);
}

if (anyTargetDistance() < m_maxFireDistance) {
Expand Down Expand Up @@ -76,7 +76,7 @@ void CruiserFightTask::updateState() {
float CruiserFightTask::anyTargetDistance() {
WorldObject* worldObject = boardComputer()->worldObject();
WorldObject* closestTarget = WorldObjectGeometryHelper::closestObject(*worldObject, &m_targets);

if (closestTarget) {
return glm::length(worldObject->transform().position() - closestTarget->transform().position())
- worldObject->bounds().minimalGridSphere().radius() * worldObject->transform().scale()
Expand All @@ -89,4 +89,4 @@ float CruiserFightTask::anyTargetDistance() {
void CruiserFightTask::setState(State newState) {
m_stateChanged = true;
m_state = newState;
}
}
6 changes: 3 additions & 3 deletions src/ai/basictasks/directsuicidetask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

DirectSuicideTask::DirectSuicideTask(BoardComputer* boardComputer, WorldObject* target) :
AiTask(boardComputer),
m_target(target ? target->handle() : Handle<WorldObject>(nullptr))
m_target(target ? target->handle<WorldObject>() : Handle<WorldObject>())
{
}

void DirectSuicideTask::setTarget(WorldObject* target) {
m_target = (target ? target->handle() : Handle<WorldObject>(nullptr));
m_target = (target ? target->handle<WorldObject>() : Handle<WorldObject>());
}

void DirectSuicideTask::update(float deltaSec) {
WorldObject* worldObject = boardComputer()->worldObject();

if (m_target.valid()) {
glm::vec3 targetPoint = m_target->physics().projectedTransformIn(0.1f).position();
glm::vec3 targetPoint = m_target->physics().speed().moved(m_target->transform(), 0.1f).position();
boardComputer()->rotateTo(targetPoint);
glm::vec3 targetDirection = glm::inverse(worldObject->transform().orientation()) * (targetPoint - worldObject->transform().position());
float angle = GeometryHelper::angleBetween(glm::vec3(0, 0, -1), targetDirection);
Expand Down
2 changes: 1 addition & 1 deletion src/ai/basictasks/fighterfighttask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void FighterFightTask::update(float deltaSec) {
boardComputer()->rotateTo(m_primaryTarget->transform().position());
boardComputer()->moveTo(m_primaryTarget->transform().position());
if (angleToTarget() < 15.0f && targetDistance() < m_maxRocketDistance) {
boardComputer()->shootRockets(m_primaryTarget->handle());
boardComputer()->shootRockets(m_primaryTarget);
}
}
if (targetDistance() < m_maxFireDistance) {
Expand Down
3 changes: 2 additions & 1 deletion src/ai/basictasks/fighttask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ void FightTask::setTargets(const std::vector<Handle<WorldObject>>& targets) {

bool FightTask::isFinished() {
return m_task->isFinished();
}
}

10 changes: 4 additions & 6 deletions src/ai/boardcomputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const EngineState& BoardComputer::engineState() const {
}

void BoardComputer::moveTo(const glm::vec3& position, bool decelerate) {
glm::vec3 projectedPosition = m_worldObject->physics().projectedTransformIn(1.0f).position();
glm::vec3 projectedPosition = m_worldObject->physics().speed().moved(m_worldObject->transform(), 1.0f).position();
glm::vec3 delta = position - projectedPosition;
float distance = glm::length(delta);

Expand Down Expand Up @@ -64,7 +64,7 @@ void BoardComputer::rotateTo(const glm::vec3& position, const glm::vec3& up) {
glm::vec3 accumulatedEuler;

// A guess (hack) where the WorldObject will point to in one second, in the local coordinate-sys
glm::quat projectedOrientation = glm::inverse(m_worldObject->transform().orientation()) * m_worldObject->physics().projectedTransformIn(0.1f).orientation();
glm::quat projectedOrientation = glm::inverse(m_worldObject->transform().orientation()) * m_worldObject->physics().speed().moved(m_worldObject->transform(), 0.1f).orientation();
glm::vec3 projectedDirection = projectedOrientation * glm::vec3(0, 0, -1);

// Direction to the target, in the local coordinate-sys
Expand Down Expand Up @@ -135,10 +135,8 @@ void BoardComputer::shootBullet(const std::vector<Handle<WorldObject>>& targets)
}
}

void BoardComputer::shootRockets(Handle<WorldObject>& target) {
if (target.valid()) {
m_worldObject->components().fireAtObject(target.get());
}
void BoardComputer::shootRockets(WorldObject* target) {
m_worldObject->components().fireAtObject(target);
}

void BoardComputer::update(float deltaSec) {
Expand Down
2 changes: 1 addition & 1 deletion src/ai/boardcomputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BoardComputer {
void rotateTo(const glm::vec3& position, const glm::vec3& up = glm::vec3(0, 0, 0));

void shootBullet(const std::vector<Handle<WorldObject>>& targets);
void shootRockets(Handle<WorldObject>& target);
void shootRockets(WorldObject* target);

void update(float deltaSec);

Expand Down
2 changes: 1 addition & 1 deletion src/ai/grouptasks/defendareatask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool DefendAreaTask::isEnemyInRange() {
if (ship) {
Faction& enemyFaction = ship->character()->faction();
if (enemyFaction.relationTo(m_squad.leader()->character()->faction()).type() == FactionRelationType::Enemy) {
m_enemies.push_back(worldObject->handle());
m_enemies.push_back(worldObject->handle<WorldObject>());
} else {
continue;
}
Expand Down
Loading