-
Notifications
You must be signed in to change notification settings - Fork 2
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
mrzzzrm
wants to merge
50
commits into
master
Choose a base branch
from
bulletengine
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
BulletEngine #579
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
7dde0f5
added bulletengine-skeleton
84fe57d
intermediate
fd9e8c7
stripped projectile of WorldObject inheritance
04cdfaa
Merge branch 'master' of github.com:voxelinc/voxellancer into bullete…
0eba1e9
move Bullet::passiveForCollisionDetection to WorldObjectBullet
5d6da02
mv genericbullet.* -> genericworldobjectbullet.*
39856fb
WorldObjectBuilder -> WorldElementBuilder
32feb48
Make WorldElementBuilder decide based on .ini whether a bullet is ins…
d559196
intermediate
b351273
Established skeleton pipeline for rendering InstancedBullets via Inst…
03ef757
intermediate
c97abd7
intermediate
9f24f02
intermediate
e521280
intermediate on bulletengine
830a586
something related to bulletengine
1008a70
merge with master
9275ac1
implemented instancedbullet
d453d67
continue bulletengine
7c78172
merge with origin
671d34a
intermediate
0436069
initial somehow working version of bulletengine
5fe8c51
Merge branch 'handle_improvements' of github.com:voxelinc/voxellancer…
0c58138
bulletengine working without collision and continuous rotation
fd860a2
Merge branch 'worldtreenoderef' of github.com:voxelinc/voxellancer in…
57b2e2e
bulletengine continues
2775f4b
bulletengine improvements
75a7a90
continue bulletengine
cb7746d
BulletEngine: Better removal strategy of InstancedBullets
bf2e214
continue bulletengine
adf8449
Fixed crah on contextreplace
dc572e8
enable hitSound and emissiveness on instancedbullets
bfd7c96
add docu to bulletengine/
5f68045
merge with master
7293f7d
fix Windows compile
gersseba 203ea81
compiling again
f5d9bdf
add drawable
a4f1bc4
Merge branch 'bulletengine' of github.com:voxelinc/voxellancer into b…
22c3c10
trying to fix it
68f8e14
bulletengine working again. glowsquad, you better not cross my path t…
6a41261
remove drawable again
1639a8a
merge with master
eeaf6a9
Splitrockets also split if target is dead; Bullet::extent
832d9eb
remove outcommented logging
5a250cf
replaced voxelparticleengine::time with UWT ;)
b5e6552
merge with master
825025a
Renamed WorldElementBuilder to VoxelObjectBuilder
68ac315
merge with master
eb070fd
add virtual to VoxelParticleEngine-destructor decl.
472f591
Merge branch 'master' of github.com:voxelinc/voxellancer into bullete…
bb21df7
fixed indentation in src/geometry/line.inl
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[general] | ||
type=worldobject | ||
type=other | ||
voxelcluster=banner.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[general] | ||
type=worldobject | ||
type=other | ||
voxelcluster=cake.csv | ||
scale=3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[general] | ||
type=worldobject | ||
type=other | ||
voxelcluster=idareyou.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[general] | ||
type=worldobject | ||
type=other | ||
voxelcluster=missionstart.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "bulletengine.h" | ||
|
||
#include <iostream> | ||
|
||
#include "equipment/weapons/worldobjectbullet.h" | ||
|
||
#include "bulletenginerenderer.h" | ||
#include "instancedbullet.h" | ||
#include "instancedbulletcontainer.h" | ||
#include "instancedbulletcontainerrenderer.h" | ||
|
||
|
||
BulletEngine::BulletEngine(): | ||
m_renderer(new BulletEngineRenderer()) | ||
{ | ||
} | ||
|
||
BulletEngine::~BulletEngine() = default; | ||
|
||
BulletEngineRenderer& BulletEngine::renderer() { | ||
return *m_renderer; | ||
} | ||
|
||
void BulletEngine::add(InstancedBullet* bullet) { | ||
container(bullet->name())->add(bullet); | ||
m_bullets.insert(std::unique_ptr<InstancedBullet>(bullet)); | ||
} | ||
|
||
InstancedBulletContainer* BulletEngine::container(const std::string& name) { | ||
auto iter = m_containers.find(name); | ||
if (iter == m_containers.end()) { | ||
iter = m_containers.emplace(name, std::unique_ptr<InstancedBulletContainer>(new InstancedBulletContainer(*this, name))).first; | ||
m_renderer->add(iter->second.get()); | ||
} | ||
return iter->second.get(); | ||
} | ||
|
||
InstancedBullet* BulletEngine::createBullet(const std::string& name) { | ||
return new InstancedBullet(container(name)->handle<InstancedBulletContainer>(), name); | ||
} | ||
|
||
void BulletEngine::update(float deltaSec) { | ||
for (auto iter = m_bullets.begin(); iter != m_bullets.end();) { | ||
InstancedBullet* bullet = iter->get(); | ||
|
||
bullet->update(deltaSec); | ||
if (bullet->alive()) { | ||
++iter; | ||
} else { | ||
bullet->container()->remove(bullet); | ||
iter = m_bullets.erase(iter); | ||
} | ||
} | ||
|
||
for (auto& pair : m_containers) { | ||
pair.second->update(deltaSec); | ||
} | ||
} | ||
|
||
void BulletEngine::draw(const Camera& camera) { | ||
m_renderer->draw(camera); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <unordered_set> | ||
|
||
|
||
class BulletEngineRenderer; | ||
class Camera; | ||
class InstancedBullet; | ||
class InstancedBulletContainer; | ||
|
||
/** | ||
* Responsible for much more performant handling of bullets instead of simulating them | ||
* like full WorldObjects | ||
* Holds the InstancedBullets of a World and their respective InstancedBulletContainers | ||
*/ | ||
class BulletEngine { | ||
public: | ||
BulletEngine(); | ||
~BulletEngine(); | ||
|
||
BulletEngineRenderer& renderer(); | ||
|
||
void add(InstancedBullet* bullet); | ||
|
||
/** | ||
* Retrieve or create the InstancedBulletContainer of the given name | ||
*/ | ||
InstancedBulletContainer* container(const std::string& name); | ||
|
||
/** | ||
* Create the InstancedBullet with the given name and connect it with its | ||
* respective InstancedBulletContainer | ||
*/ | ||
InstancedBullet* createBullet(const std::string& name); | ||
|
||
void update(float deltaSec); | ||
void draw(const Camera& camera); | ||
|
||
|
||
protected: | ||
std::unordered_map<std::string, std::unique_ptr<InstancedBulletContainer>> m_containers; | ||
std::unordered_set<std::unique_ptr<InstancedBullet>> m_bullets; | ||
std::unique_ptr<BulletEngineRenderer> m_renderer; | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?