Compare commits

..

22 Commits

Author SHA1 Message Date
stiffly a3ab844cc4 Makes sure m_CurrentSelection is valid before using it. 2016-03-11 11:12:49 +01:00
stiffly 03493df213 Merge remote-tracking branch 'origin/master' into EntitiesWithoutTransform 2016-03-11 11:06:23 +01:00
verysecrethero 0869afd529 Merge pull request #193 from teamfisk/BoxModelCollision
Removed collision jittering effects
2016-03-11 10:48:25 +01:00
Adam Byléhn 56a13d03fc Merge pull request #197 from teamfisk/SpectatorCamera
Properly unlocked mouse
2016-03-11 10:43:29 +01:00
Adam Byléhn dad18a200f Merge pull request #202 from teamfisk/Trigger
Triggersystem updated for the capturepoints
2016-03-11 10:38:20 +01:00
FakeShemp 937bf823f3 Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-10 21:59:23 +01:00
FakeShemp e35b09cc68 Add alpha clipping
Tobbe sa att jag fick pusha direkt
2016-03-10 21:59:01 +01:00
William Moberg b172526e62 Merge pull request #199 from teamfisk/CapturePointTake
The children of the CapturePointModels now also get their visibility changed
2016-03-10 16:37:53 +01:00
verysecrethero 551745b0a6 Merge remote-tracking branch 'origin/master' into CapturePointTake 2016-03-10 16:14:18 +01:00
William Moberg d6e3a47182 Merge branch 'master' into Trigger 2016-03-10 16:14:17 +01:00
verysecrethero 8b89df0095 Changed to a better validator 2016-03-10 16:09:54 +01:00
William Moberg 038a706e28 Don't collide against disabled (invisible) models. Triggers uses model vs. box instead of only box vs. box. 2016-03-10 16:05:30 +01:00
FakeShemp b094b9feca Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-10 15:01:27 +01:00
verysecrethero 0a94373f3f The children of the CapturePointModels now also get their visibility on/off. This is done since a capturepoint is actually 2 models and not just 1 2016-03-10 14:38:20 +01:00
William Moberg bdcb33d992 Mouse always unlocked on game start and on disconnecting (i.e when menu shows). 2016-03-10 12:46:06 +01:00
William Moberg 8a8c375d3a Merge remote-tracking branch 'origin/master' into BoxModelCollision 2016-03-10 09:57:33 +01:00
William Moberg 8936b3d6c3 Probably fixed all the jittering, won't need the jitter guard anymore. 2016-03-09 19:45:26 +01:00
William Moberg 8a3564ad49 Merge remote-tracking branch 'origin/master' into BoxModelCollision 2016-03-09 18:03:39 +01:00
William Moberg 9581e9ac84 Don't set the player to previous position when uncrouching. 2016-03-09 17:51:26 +01:00
FakeShemp 7ced9e6767 Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-08 17:25:03 +01:00
stiffly 9cc8124847 Renamed IsAnyParentMissingTransform -> isAnyParentMissingTransform (member function). 2016-03-07 14:34:45 +01:00
stiffly a369c26a28 Blend tree nodes can now exist without transform components, without the game crashing. 2016-03-07 14:19:22 +01:00
28 changed files with 315 additions and 493 deletions
+1 -1
Submodule assets updated: 298641b1af...007b54bd67
+12
View File
@@ -84,6 +84,18 @@ bool AABBvsTriangles(const AABB& box,
const std::vector<unsigned int>& modelIndices, const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix); const glm::mat4& modelMatrix);
enum Output
{
OutContained,
OutSeparated,
OutIntersecting
};
//Detects intersection and containment.
Output AABBvsTrianglesWContainment(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix);
//Return true if the boxes are intersecting. //Return true if the boxes are intersecting.
bool AABBVsAABB(const AABB& a, const AABB& b); bool AABBVsAABB(const AABB& a, const AABB& b);
//Return true if the boxes are intersecting. //Return true if the boxes are intersecting.
+1
View File
@@ -47,6 +47,7 @@ private:
// Utility functions // Utility functions
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath); EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
void setWidgetMode(EditorGUI::WidgetMode mode); void setWidgetMode(EditorGUI::WidgetMode mode);
bool isAnyParentMissingTransform(EntityID entityID);
// GUI callbacks // GUI callbacks
void OnEntitySelected(EntityWrapper entity); void OnEntitySelected(EntityWrapper entity);
@@ -19,6 +19,7 @@ public:
virtual const glm::vec3 Rotation() const { return m_Rotation; } virtual const glm::vec3 Rotation() const { return m_Rotation; }
virtual bool Jumping() const { return m_Jumping; } virtual bool Jumping() const { return m_Jumping; }
virtual bool Crouching() const { return m_Crouching; } virtual bool Crouching() const { return m_Crouching; }
virtual bool CrouchingLastFrame() const { return m_CrouchingLastFrame; }
virtual bool DoubleJumping() const { return m_DoubleJumping; } virtual bool DoubleJumping() const { return m_DoubleJumping; }
virtual void SetDoubleJumping(bool isDoubleJumping) { virtual void SetDoubleJumping(bool isDoubleJumping) {
m_DoubleJumping = isDoubleJumping; m_DoubleJumping = isDoubleJumping;
@@ -44,6 +45,7 @@ protected:
bool m_Jumping = false; bool m_Jumping = false;
bool m_DoubleJumping = false; bool m_DoubleJumping = false;
bool m_Crouching = false; bool m_Crouching = false;
bool m_CrouchingLastFrame = false;
//assault dash membervariables - needed to calculate the doubletap- and dashlogic //assault dash membervariables - needed to calculate the doubletap- and dashlogic
double m_AssaultDashDoubleTapDeltaTime = 0.0; double m_AssaultDashDoubleTapDeltaTime = 0.0;
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable), //i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
@@ -82,6 +84,7 @@ void FirstPersonInputController<EventContext>::Reset()
{ {
m_Rotation = glm::vec3(0.f, 0.f, 0.f); m_Rotation = glm::vec3(0.f, 0.f, 0.f);
m_Jumping = false; m_Jumping = false;
m_CrouchingLastFrame = m_Crouching;
} }
template <typename EventContext> template <typename EventContext>
@@ -30,6 +30,7 @@ private:
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e); bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured; EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
bool CapturePointSystem::OnCaptured(const Events::Captured& e); bool CapturePointSystem::OnCaptured(const Events::Captured& e);
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
bool m_WinnerWasFound = false; bool m_WinnerWasFound = false;
//need to track these variables for the captureSystem to work as per design! //need to track these variables for the captureSystem to work as per design!
@@ -3,6 +3,7 @@
#include "Core/System.h" #include "Core/System.h"
#include "Input/EInputCommand.h" #include "Input/EInputCommand.h"
#include "Network/EPlayerDisconnected.h"
class SpectatorCameraSystem : public ImpureSystem class SpectatorCameraSystem : public ImpureSystem
{ {
@@ -17,6 +18,8 @@ private:
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand; EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e); bool OnInputCommand(const Events::InputCommand& e);
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
bool OnDisconnect(const Events::PlayerDisconnected& e);
}; };
#endif #endif
@@ -27,12 +27,9 @@ private:
std::random_device m_RandomDevice; std::random_device m_RandomDevice;
std::mt19937 m_RandomEngine; std::mt19937 m_RandomEngine;
// Weapon functions // Weapon functions
void fireShell(ComponentWrapper cWeapon, WeaponInfo& wi); void fireShell(ComponentWrapper cWeapon, WeaponInfo& wi);
void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, const std::vector<glm::vec2>& pattern); void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage);
void spawnTracers(ComponentWrapper cWeapon, WeaponInfo& wi, std::vector<glm::vec2> pattern);
bool canFire(ComponentWrapper cWeapon, WeaponInfo& wi); bool canFire(ComponentWrapper cWeapon, WeaponInfo& wi);
// Utility // Utility
+3 -1
View File
@@ -29,4 +29,6 @@ K=TakeDamage,1500
F2=PerformanceTimingResetAllTimers F2=PerformanceTimingResetAllTimers
F3=PerformanceTimingCreateExcelData F3=PerformanceTimingCreateExcelData
Comma=SwapToClassPick Comma=SwapToClassPick
Period=SwapToTeamPick Period=SwapToTeamPick
Enter=PickClass,1
F5=DisconnectFromServer
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DefenderWeapon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DefenderWeapon.xsd"> <DefenderWeapon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DefenderWeapon.xsd">
<Slot><Primary/></Slot> <Slot><Primary/></Slot>
<MagazineAmmo>9999</MagazineAmmo> <MagazineAmmo>8</MagazineAmmo>
<MagazineSize>8</MagazineSize> <MagazineSize>8</MagazineSize>
<Ammo>64</Ammo> <Ammo>64</Ammo>
<MaxAmmo>64</MaxAmmo> <MaxAmmo>64</MaxAmmo>
<BaseDamage>90</BaseDamage> <BaseDamage>90</BaseDamage>
<SpreadAngle>10</SpreadAngle> <SpreadAngle>0.174533</SpreadAngle> <!-- 0.174533 = 10 degrees -->
<MaxTravelAngle>0.174533</MaxTravelAngle> <!-- 0.174533 = 10 degrees --> <MaxTravelAngle>0.174533</MaxTravelAngle> <!-- 0.174533 = 10 degrees -->
<NumPellets>9</NumPellets> <NumPellets>10</NumPellets>
<RPM>120</RPM> <RPM>120</RPM>
<ViewPunch>0.03</ViewPunch> <ViewPunch>0.03</ViewPunch>
<ViewReturnSpeed>0.2</ViewReturnSpeed> <ViewReturnSpeed>0.2</ViewReturnSpeed>
@@ -36,7 +36,7 @@
<xs:annotation><xs:documentation>Damage dealt if all shotgun pellets hit</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Damage dealt if all shotgun pellets hit</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="SpreadAngle" type="t:float" minOccurs="0"> <xs:element name="SpreadAngle" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>The spread angle radius.</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Spread angle in radians</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="MaxTravelAngle" type="t:float" minOccurs="0"> <xs:element name="MaxTravelAngle" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Maximum vertical aim travel angle in radians</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Maximum vertical aim travel angle in radians</xs:documentation></xs:annotation>
-94
View File
@@ -1,94 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Orientation X="0" Y="0.174532995" Z="0"/>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+23 -79
View File
@@ -1,95 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="Shield" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:Transform> <c:Blend>
<Position X="1.70262027" Y="0.261695802" Z="-3.26634645"/> <Pose1>Deploy</Pose1>
</c:Transform> <Pose2>Idle</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Model>
<Resource>Models/Characters/Defender/DefenderShield.mesh</Resource>
</c:Model>
<c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="Back"> <Entity name="Deploy">
<Components> <Components>
<c:Blend> <c:Animation>
<Pose1>Deploy</Pose1> <AnimationName>ActivateDeactiveShieldF</AnimationName>
<Pose2>Idle</Pose2> <Time>1</Time>
<Weight>0</Weight> <Speed>1</Speed>
</c:Blend> </c:Animation>
<c:Shielded/>
<c:Model>
<Resource>Models/Characters/Defender/DefenderShieldBack.mesh</Resource>
<Color A="0.219607845" B="3.92156863" G="1" R="1"/>
<Shadow>false</Shadow>
<Transparent>true</Transparent>
<NormalMap>false</NormalMap>
<DiffuseTexture>false</DiffuseTexture>
<SpecularMap>false</SpecularMap>
<GlowMap>false</GlowMap>
</c:Model>
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children/>
<Entity name="Deploy">
<Components>
<c:Animation>
<AnimationName>ActivateDeactiveShieldF</AnimationName>
<Play>true</Play>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>ShieldFrontF</AnimationName>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity> </Entity>
<Entity name="Front"> <Entity name="Idle">
<Components> <Components>
<c:Blend> <c:Animation>
<Pose1>Deploy</Pose1> <AnimationName>ShieldFrontF</AnimationName>
<Pose2>Idle</Pose2> <Speed>1</Speed>
<Weight>0</Weight> </c:Animation>
</c:Blend>
<c:Model>
<Resource>Models/Characters/Defender/DefenderShieldFront.mesh</Resource>
<Color A="0.219607845" B="3.92156863" G="1" R="1"/>
<Shadow>false</Shadow>
<Transparent>true</Transparent>
<NormalMap>false</NormalMap>
<DiffuseTexture>false</DiffuseTexture>
<SpecularMap>false</SpecularMap>
<GlowMap>false</GlowMap>
</c:Model>
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children/>
<Entity name="Deploy">
<Components>
<c:Animation>
<AnimationName>ActivateDeactiveShieldF</AnimationName>
<Play>true</Play>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>ShieldFrontF</AnimationName>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity> </Entity>
</Children> </Children>
-27
View File
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Lifetime>
<Lifetime>10</Lifetime>
</c:Lifetime>
<c:ExplosionEffect>
<Velocity X="2" Y="2.30000019" Z="0"/>
<ExplosionDuration>1</ExplosionDuration>
<Randomness>true</Randomness>
<ExponentialAccelaration>true</ExponentialAccelaration>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/Core/UnitSphere.mesh</Resource>
<Color A="1" B="1" G="1" R="3.92156863"/>
<Shadow>false</Shadow>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
</c:Transform>
</Components>
<Children/>
</Entity>
+4 -96
View File
@@ -103,7 +103,7 @@
<Color A="1" B="1" G="0.254901975" R="0"/> <Color A="1" B="1" G="0.254901975" R="0"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="0.800000012" Y="0" Z="0"/> <Position X="-0.600000024" Y="0" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children/>
@@ -116,7 +116,7 @@
<Color A="1" B="1" G="0.254901975" R="0"/> <Color A="1" B="1" G="0.254901975" R="0"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="-0.600000024" Y="0" Z="0.549540162"/> <Position X="0.800000012" Y="0" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children/>
@@ -157,106 +157,14 @@
<Resource>Models/Weapons/Blue/DefenderWeaponBlue.mesh</Resource> <Resource>Models/Weapons/Blue/DefenderWeaponBlue.mesh</Resource>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Orientation X="0" Y="-0" Z="0"/> <Position X="0.00681143999" Y="-0.204994932" Z="-0.209244296"/>
<Orientation X="-0.581807375" Y="0.562133908" Z="-0.0719003305"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
<Entity>
<Components>
<c:Transform>
<Position X="0.870232701" Y="0.640069604" Z="4.07769537"/>
<Orientation X="0" Y="4.71238565" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Orientation X="0" Y="0.174532995" Z="0"/>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children> </Children>
</Entity> </Entity>
+1 -1
View File
@@ -3,7 +3,7 @@
<Components> <Components>
<c:Lifetime> <c:Lifetime>
<Lifetime>10</Lifetime> <Lifetime>0.10000000149011612</Lifetime>
</c:Lifetime> </c:Lifetime>
<c:Transform> <c:Transform>
<Scale X="0" Y="1" Z="1"/> <Scale X="0" Y="1" Z="1"/>
@@ -99,7 +99,7 @@
</c:Team> </c:Team>
<c:PlayerSpawn/> <c:PlayerSpawn/>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/Player.xml</EntityFile> <EntityFile>Schema/Entities/PlayerRed.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Transform/> <c:Transform/>
</Components> </Components>
@@ -225,6 +225,11 @@
</Team> </Team>
</c:Team> </c:Team>
<c:Trigger/> <c:Trigger/>
<c:Model>
<Resource></Resource>
<Color A="0.300000012" B="0" G="0" R="1"/>
<Visible>false</Visible>
</c:Model>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="-4.10000038"/> <Position X="0" Y="0" Z="-4.10000038"/>
</c:Transform> </c:Transform>
@@ -239,7 +244,17 @@
<Scale X="2.70000005" Y="3.4000001" Z="4.60000038"/> <Scale X="2.70000005" Y="3.4000001" Z="4.60000038"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children>
<Entity>
<Components>
<c:Model>
<Resource></Resource>
</c:Model>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity> </Entity>
<Entity name="Blue"> <Entity name="Blue">
<Components> <Components>
+50 -14
View File
@@ -360,7 +360,14 @@ constexpr bool FaceIsGround(float faceNormalY)
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 } //An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) }); constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
bool AABBvsTriangle(const AABB& box, enum class BoxTriRes
{
Front,
Behind,
Intersect
};
BoxTriRes AABBvsTriangle(const AABB& box,
const std::array<glm::vec3, 3>& triPos, const std::array<glm::vec3, 3>& triPos,
const glm::vec3& originalBoxVelocity, const glm::vec3& originalBoxVelocity,
float verticalStepHeight, float verticalStepHeight,
@@ -374,7 +381,7 @@ bool AABBvsTriangle(const AABB& box,
//Less checks, and we should be able to walk out from models if we are trapped inside. //Less checks, and we should be able to walk out from models if we are trapped inside.
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]); glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) { if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
return false; return BoxTriRes::Behind;
} }
triNormal = glm::normalize(triNormal); triNormal = glm::normalize(triNormal);
@@ -409,6 +416,9 @@ bool AABBvsTriangle(const AABB& box,
const glm::vec3& min = box.MinCorner(); const glm::vec3& min = box.MinCorner();
const glm::vec3& max = box.MaxCorner(); const glm::vec3& max = box.MaxCorner();
// If there is no intersection, whether the box center is in front of or behind the triangle.
BoxTriRes noIntersection = glm::dot(triNormal, origin - triPos[0]) > 0 ? BoxTriRes::Front : BoxTriRes::Behind;
//For each projection in xy-, xz-, and yx-planes. //For each projection in xy-, xz-, and yx-planes.
for (std::pair<int, int> dim : dimensionPairs) { for (std::pair<int, int> dim : dimensionPairs) {
//2D Triangle. //2D Triangle.
@@ -426,7 +436,7 @@ bool AABBvsTriangle(const AABB& box,
bool pushedFromTriangleLine; bool pushedFromTriangleLine;
//if projections don't overlap, return false. //if projections don't overlap, return false.
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) { if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
return false; return noIntersection;
} else if (resolveCollision) { } else if (resolveCollision) {
//Overwrite the smallest resolution if this is smaller. //Overwrite the smallest resolution if this is smaller.
if (resolutionDist < resolveShortest.DistanceSq) { if (resolutionDist < resolveShortest.DistanceSq) {
@@ -462,14 +472,15 @@ bool AABBvsTriangle(const AABB& box,
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal); float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
//If intersection point between plane and diagonal is within the box. //If intersection point between plane and diagonal is within the box.
if (glm::abs(t) > 1) { if (glm::abs(t) > 1) {
return false; return noIntersection;
} }
if (!resolveCollision) { if (!resolveCollision) {
return true; return BoxTriRes::Intersect;
} }
glm::vec3 cornerResolution = (1+t) * diagonal; glm::vec3 cornerResolution = (1+t) * diagonal;
cornerResolution = glm::dot(cornerResolution, triNormal) * triNormal;
//Overwrite the smallest resolution if cornerResolution is smaller. //Overwrite the smallest resolution if cornerResolution is smaller.
float lenSq = glm::length2(cornerResolution); float lenSq = glm::length2(cornerResolution);
if (lenSq < resolveShortest.DistanceSq) { if (lenSq < resolveShortest.DistanceSq) {
@@ -498,7 +509,7 @@ bool AABBvsTriangle(const AABB& box,
case ResolveDimZ: case ResolveDimZ:
//If we get here, the resolution is along one coordinate axis. //If we get here, the resolution is along one coordinate axis.
//set velocity to 0 in y if it is along y-axis. //set velocity to 0 in y if it is along y-axis.
return true; return BoxTriRes::Intersect;
case Line: case Line:
projNorm = glm::normalize(outResolution); projNorm = glm::normalize(outResolution);
break; break;
@@ -533,10 +544,10 @@ bool AABBvsTriangle(const AABB& box,
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm; boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
} }
} }
return true; return BoxTriRes::Intersect;
} }
bool AABBvsTriangles(const AABB& box, Output AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices, const RawModel::Vertex* modelVertices,
const std::vector<unsigned int>& modelIndices, const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix, const glm::mat4& modelMatrix,
@@ -546,8 +557,8 @@ bool AABBvsTriangles(const AABB& box,
glm::vec3& outResolutionVector, glm::vec3& outResolutionVector,
bool resolveCollision) bool resolveCollision)
{ {
bool hit = false; bool intersect = false;
Output out = Output::OutContained;
bool everHitTheGround = false; bool everHitTheGround = false;
AABB newBox = box; AABB newBox = box;
outResolutionVector = glm::vec3(0.f); outResolutionVector = glm::vec3(0.f);
@@ -560,20 +571,27 @@ bool AABBvsTriangles(const AABB& box,
}; };
glm::vec3 outVec; glm::vec3 outVec;
bool collideWithGround = isOnGround; bool collideWithGround = isOnGround;
if (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) { switch (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
hit = true; case Collision::BoxTriRes::Front:
out = Output::OutSeparated;
break;
case Collision::BoxTriRes::Intersect:
intersect = true;
outResolutionVector += outVec; outResolutionVector += outVec;
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size()); newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
if (collideWithGround) { if (collideWithGround) {
everHitTheGround = isOnGround = true; everHitTheGround = isOnGround = true;
} }
break;
default:
break;
} }
} }
if (!everHitTheGround) { if (!everHitTheGround) {
isOnGround = false; isOnGround = false;
} }
return hit; return intersect ? Output::OutIntersecting : out;
} }
bool AABBvsTriangles(const AABB& box, bool AABBvsTriangles(const AABB& box,
@@ -593,13 +611,31 @@ bool AABBvsTriangles(const AABB& box,
verticalStepHeight, verticalStepHeight,
isOnGround, isOnGround,
outResolutionVector, outResolutionVector,
true); true) == Output::OutIntersecting;
} }
bool AABBvsTriangles(const AABB& box, bool AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices, const RawModel::Vertex* modelVertices,
const std::vector<unsigned int>& modelIndices, const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix) const glm::mat4& modelMatrix)
{
glm::vec3 vel, outres;
bool g;
return AABBvsTriangles(box,
modelVertices,
modelIndices,
modelMatrix,
vel,
0.f,
g,
outres,
false) == Output::OutIntersecting;
}
Output AABBvsTrianglesWContainment(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix)
{ {
glm::vec3 vel, outres; glm::vec3 vel, outres;
bool g; bool g;
+10 -3
View File
@@ -37,6 +37,10 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
bool hit; bool hit;
float dist; float dist;
if (boxB.Entity.HasComponent("Model")) { if (boxB.Entity.HasComponent("Model")) {
if (!((bool)boxB.Entity["Model"]["Visible"])) {
// Don't collide against invisible models.
continue;
}
RawModel* model; RawModel* model;
std::string res = (std::string)boxB.Entity["Model"]["Resource"]; std::string res = (std::string)boxB.Entity["Model"]["Resource"];
try { try {
@@ -77,7 +81,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
} }
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) { if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
//Here we know boxB is a entity with Collideable, AABB, and Model. // Here we know boxB is a entity with Collideable, AABB, and Model.
if (!((bool)boxB.Entity["Model"]["Visible"])) {
// Don't collide against invisible models.
continue;
}
RawModel* model; RawModel* model;
try { try {
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]); model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
@@ -88,12 +96,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
bool isOnGround = (bool)cPhysics["IsOnGround"]; bool isOnGround = (bool)cPhysics["IsOnGround"];
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. //Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector; (glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity); boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity; cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) { if (isOnGround) {
+31 -10
View File
@@ -10,6 +10,16 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
return; return;
} }
RawModel* triggerModel = nullptr;
glm::mat4 triggerModelMat;
if (triggerEntity.HasComponent("Model")) {
try {
triggerModel = ResourceManager::Load<RawModel, true>(triggerEntity["Model"]["Resource"]);
triggerModelMat = Transform::ModelMatrix(triggerEntity);
} catch (const std::exception&) {
}
}
m_OctreeOut.clear(); m_OctreeOut.clear();
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut); m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
@@ -22,7 +32,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
if (colliderFitsInTrigger) { if (colliderFitsInTrigger) {
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size()); completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
} }
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox)) {
// We know the entity is inside the trigger box, but perhaps not the model yet.
Collision::Output out = triggerModel == nullptr
? Collision::Output::OutContained
: Collision::AABBvsTrianglesWContainment(
colliderBox,
triggerModel->Vertices(),
triggerModel->m_Indices,
triggerModelMat);
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox) && out == Collision::Output::OutContained) {
// Entity is completely inside the trigger. // Entity is completely inside the trigger.
// If it was only touching before, it is erased. // If it was only touching before, it is erased.
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity); m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
@@ -32,7 +52,8 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
completeSet.insert(colliderEntity); completeSet.insert(colliderEntity);
publish<Events::TriggerEnter>(colliderEntity, triggerEntity); publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
} }
} else { continue;
} else if (out != Collision::Output::OutSeparated) {
// Entity is only touching the trigger. // Entity is only touching the trigger.
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity]; auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity]; auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
@@ -47,17 +68,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
touchSet.insert(colliderEntity); touchSet.insert(colliderEntity);
} }
// Else, it was touching the trigger last frame too and nothing is done. // Else, it was touching the trigger last frame too and nothing is done.
}
} else {
// Entity is not touching the trigger,
// Throw event if it was previously.
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
continue; continue;
} }
// This only occurs if the entity was completely inside the trigger one frame,
// then completely outside the trigger, e.g. when dying and respawning.
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
} }
// Only get here if entity is not touching the trigger,
// throw event if it was touching previously.
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
continue;
}
// This only occurs if the entity was completely inside the trigger one frame,
// then completely outside the trigger, e.g. when dying and respawning.
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
} }
} }
+1 -13
View File
@@ -27,7 +27,7 @@ void EntityWrapper::AttachComponent(const char* componentName)
EntityWrapper EntityWrapper::Parent() EntityWrapper EntityWrapper::Parent()
{ {
if (!Valid()) { if (this->World == nullptr || this->ID == EntityID_Invalid) {
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} else { } else {
return EntityWrapper(this->World, this->World->GetParent(this->ID)); return EntityWrapper(this->World, this->World->GetParent(this->ID));
@@ -36,10 +36,6 @@ EntityWrapper EntityWrapper::Parent()
EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityName) EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityName)
{ {
if (!Valid()) {
return EntityWrapper::Invalid;
}
EntityWrapper entity = *this; EntityWrapper entity = *this;
while (entity.Parent().Valid()) { while (entity.Parent().Valid()) {
entity = entity.Parent(); entity = entity.Parent();
@@ -52,10 +48,6 @@ EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityNa
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name) EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
{ {
if (!Valid()) {
return EntityWrapper::Invalid;
}
return firstChildByNameRecursive(name, this->ID); return firstChildByNameRecursive(name, this->ID);
} }
@@ -86,10 +78,6 @@ EntityWrapper EntityWrapper::FirstLevelChildByName(const std::string& name)
EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType) EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType)
{ {
if (!Valid()) {
return EntityWrapper::Invalid;
}
EntityWrapper entity = *this; EntityWrapper entity = *this;
while (entity.Parent().Valid()) { while (entity.Parent().Valid()) {
entity = entity.Parent(); entity = entity.Parent();
+21 -3
View File
@@ -4,7 +4,7 @@
#include "Editor/EditorWidgetSystem.h" #include "Editor/EditorWidgetSystem.h"
#include "Core/EntityFile.h" #include "Core/EntityFile.h"
EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame) EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame)
: System(params) : System(params)
, m_Renderer(renderer) , m_Renderer(renderer)
, m_RenderFrame(renderFrame) , m_RenderFrame(renderFrame)
@@ -14,7 +14,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
m_EditorWorldSystemPipeline->AddSystem<UniformScaleSystem>(0); m_EditorWorldSystemPipeline->AddSystem<UniformScaleSystem>(0);
m_EditorWorldSystemPipeline->AddSystem<EditorWidgetSystem>(0, m_Renderer); m_EditorWorldSystemPipeline->AddSystem<EditorWidgetSystem>(0, m_Renderer);
m_EditorWorldSystemPipeline->AddSystem<EditorRenderSystem>(1, m_Renderer, m_RenderFrame); m_EditorWorldSystemPipeline->AddSystem<EditorRenderSystem>(1, m_Renderer, m_RenderFrame);
m_EditorCamera = importEntity(EntityWrapper(m_EditorWorld, EntityID_Invalid), "Schema/Entities/Empty.xml"); m_EditorCamera = importEntity(EntityWrapper(m_EditorWorld, EntityID_Invalid), "Schema/Entities/Empty.xml");
m_ActualCamera = m_EditorCamera; m_ActualCamera = m_EditorCamera;
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform");
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
Enable(); Enable();
} else { } else {
Disable(); Disable();
m_EventBroker->Publish(Events::UnlockMouse());
} }
} }
@@ -71,6 +72,9 @@ void EditorSystem::Update(double dt)
m_EditorStats->Draw(actualDelta); m_EditorStats->Draw(actualDelta);
if (m_CurrentSelection.Valid() && m_Widget.Valid()) { if (m_CurrentSelection.Valid() && m_Widget.Valid()) {
if (isAnyParentMissingTransform(m_CurrentSelection.ID)) {
return;
}
(glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection); (glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection);
if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) { if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
(glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection); (glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection);
@@ -78,7 +82,6 @@ void EditorSystem::Update(double dt)
(glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0); (glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0);
} }
} }
m_EditorWorldSystemPipeline->Update(actualDelta); m_EditorWorldSystemPipeline->Update(actualDelta);
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"]; ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
@@ -202,6 +205,9 @@ bool EditorSystem::OnMousePress(const Events::MousePress& e)
bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e) bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
{ {
if (m_CurrentSelection.Valid()) { if (m_CurrentSelection.Valid()) {
if (isAnyParentMissingTransform(m_CurrentSelection.ID)) {
return false;
}
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) { if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
glm::quat parentOrientation; glm::quat parentOrientation;
glm::vec3 parentScale(1.f); glm::vec3 parentScale(1.f);
@@ -308,3 +314,15 @@ void EditorSystem::setWidgetMode(EditorGUI::WidgetMode mode)
m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID); m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID);
} }
bool EditorSystem::isAnyParentMissingTransform(EntityID entityID)
{
EntityWrapper entity(m_World, entityID);
while (entity.Parent().Valid()) {
if (!entity.HasComponent("Transform")) {
return true;
}
entity = entity.Parent();
}
return false;
}
+6 -1
View File
@@ -1,4 +1,5 @@
#include "Network/Client.h" #include "Network/Client.h"
#include "Network/EPlayerDisconnected.h"
using namespace boost::asio::ip; using namespace boost::asio::ip;
Client::Client(World* world, EventBroker* eventBroker) Client::Client(World* world, EventBroker* eventBroker)
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
void Client::parseKick() void Client::parseKick()
{ {
LOG_WARNING("You have been kicked from the server."); LOG_WARNING("You have been kicked from the server.");
m_IsConnected = false; disconnect();
} }
void Client::parseSpawnEvents() void Client::parseSpawnEvents()
@@ -464,6 +465,10 @@ void Client::disconnect()
Packet packet(MessageType::Disconnect, m_SendPacketID); Packet packet(MessageType::Disconnect, m_SendPacketID);
m_Reliable.Send(packet); m_Reliable.Send(packet);
m_Reliable.Disconnect(); m_Reliable.Disconnect();
Events::PlayerDisconnected e;
e.Entity = m_LocalPlayer.ID;
e.PlayerID = -1;
m_EventBroker->Publish(e);
createMainMenu(); createMainMenu();
} }
+1 -1
View File
@@ -1232,7 +1232,7 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
} else { } else {
frameBones = modelJob->Skeleton->GetTPose(); frameBones = modelJob->Skeleton->GetTPose();
} }
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else { } else {
if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) { if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) {
@@ -10,6 +10,8 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
Enable(GL_DEPTH_TEST); Enable(GL_DEPTH_TEST);
DepthMask(GL_TRUE); DepthMask(GL_TRUE);
Enable(GL_CULL_FACE); Enable(GL_CULL_FACE);
Enable(GL_ALPHA_TEST);
AlphaFunc(GL_GEQUAL, 0.05f);
// Enable(GL_STENCIL_TEST); // Enable(GL_STENCIL_TEST);
// StencilFunc(GL_NOTEQUAL, 1, 0xFF); // StencilFunc(GL_NOTEQUAL, 1, 0xFF);
// StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+12 -4
View File
@@ -108,10 +108,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//change what model is displaying (change all in case 2 capturepoints has been captured on the same frame) //change what model is displaying (change all in case 2 capturepoints has been captured on the same frame)
for (int i = 0; i < m_NumberOfCapturePoints; i++) { for (int i = 0; i < m_NumberOfCapturePoints; i++) {
auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"]; auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"];
if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").ID != EntityID_Invalid) { if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").Valid()) {
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Red")["Model"]["Visible"] = owner == redTeam ? true : false; ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Red"), owner == redTeam);
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue")["Model"]["Visible"] = owner == blueTeam ? true : false; ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue"), owner == blueTeam);
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator")["Model"]["Visible"] = owner == spectatorTeam ? true : false; ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator"), owner == spectatorTeam);
} }
} }
//save the next cap points and publish the captured event //save the next cap points and publish the captured event
@@ -232,6 +232,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
} }
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
(bool&)capturePointModels["Model"]["Visible"] = isOwner;
for (auto& capModel : capturePointModels.ChildrenWithComponent("Model"))
{
(bool&)capModel["Model"]["Visible"] = isOwner;
}
}
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
{ {
//personEntered = e.Entity, thingEntered = e.Trigger //personEntered = e.Entity, thingEntered = e.Trigger
@@ -264,6 +264,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
size = glm::vec3(1.f, 1.f, 1.f); size = glm::vec3(1.f, 1.f, 1.f);
} else { } else {
size = glm::vec3(1.f, 1.6f, 1.f); size = glm::vec3(1.f, 1.6f, 1.f);
if (controller->CrouchingLastFrame() && isOnGround) {
// The collision should resolve this anyway, but
// this is more reliable, since the box gets larger.
((glm::vec3&)cTransform["Position"]).y += 0.3f;
}
} }
} }
+15 -1
View File
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
, m_PickedTeam(-1) , m_PickedTeam(-1)
{ {
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
} }
void SpectatorCameraSystem::Update(double dt) void SpectatorCameraSystem::Update(double dt)
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
} }
return true; return true;
} }
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
{
// If local player gets disconnected, they should be set to
// the spectator camera next time a map loads that has one.
if (e.Entity == LocalPlayer.ID) {
m_CamSetToTeamPick = false;
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
Events::UnlockMouse unlock;
m_EventBroker->Publish(unlock);
}
return true;
}
@@ -190,50 +190,60 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
magAmmo -= 1; magAmmo -= 1;
} }
// We can't really do any valuable calculations without a valid camera
if (!m_CurrentCamera.Valid()) {
return;
}
int numPellets = cWeapon["NumPellets"]; int numPellets = cWeapon["NumPellets"];
float spreadAngle = cWeapon["SpreadAngle"];
std::uniform_real_distribution<float> randomSpreadAngle(-spreadAngle, spreadAngle);
// Create a spread pattern // Calculate pellet angles
std::vector<glm::vec2> pattern; // HACK: Random for now?
// The first pellet is always centered // TODO: Make distribution even for each quadrant
pattern.push_back(glm::vec2(0, 0)); std::vector<glm::vec2> pelletAngles;
// Any additional pellets form circles around the middle for (int i = 0; i < numPellets; i++) {
int numOuterPellets = numPellets - 1; pelletAngles.push_back(glm::vec2(randomSpreadAngle(m_RandomEngine), randomSpreadAngle(m_RandomEngine)));
float angleIncrement = glm::two_pi<float>() / numOuterPellets;
for (int i = 0; i < numOuterPellets; ++i) {
float angle = angleIncrement * i;
glm::vec2 pellet = glm::vec2(glm::cos(angle), glm::sin(angle));
pattern.push_back(pellet);
} }
// Deal damage (clientside) double pelletDamage = (double)cWeapon["BaseDamage"] / numPellets;
dealDamage(cWeapon, wi, pattern);
// Spawn tracers
spawnTracers(cWeapon, wi, pattern);
// View punch // View punch
//if (IsClient) { if (IsClient) {
// EntityWrapper camera = wi.Player.FirstChildByName("Camera"); EntityWrapper camera = wi.Player.FirstChildByName("Camera");
// if (camera.Valid()) { if (camera.Valid()) {
// glm::vec3& cameraOrientation = camera["Transform"]["Orientation"]; glm::vec3& cameraOrientation = camera["Transform"]["Orientation"];
// float viewPunch = cWeapon["ViewPunch"]; float viewPunch = cWeapon["ViewPunch"];
// float maxTravelAngle = cWeapon["MaxTravelAngle"]; float maxTravelAngle = cWeapon["MaxTravelAngle"];
// float& currentTravel = cWeapon["CurrentTravel"]; float& currentTravel = cWeapon["CurrentTravel"];
// if (currentTravel < maxTravelAngle) { if (currentTravel < maxTravelAngle) {
// float change = viewPunch; float change = viewPunch;
// if (currentTravel + change > maxTravelAngle) { if (currentTravel + change > maxTravelAngle) {
// change = maxTravelAngle - currentTravel; change = maxTravelAngle - currentTravel;
// } }
// cameraOrientation.x += change; cameraOrientation.x += change;
// currentTravel += change; currentTravel += change;
// } }
// } }
//} }
// Tracers
EntityWrapper weaponModelEntity;
if (wi.Player == LocalPlayer) {
weaponModelEntity = wi.FirstPersonEntity;
} else {
weaponModelEntity = wi.ThirdPersonEntity;
}
if (weaponModelEntity.Valid()) {
EntityWrapper spawner = weaponModelEntity.FirstChildByName("WeaponMuzzle");
for (auto& angles : pelletAngles) {
glm::vec3 direction = Transform::AbsoluteOrientation(spawner) * glm::quat(glm::vec3(angles, 0.f)) * glm::vec3(0, 0, -1);
float distance = traceRayDistance(Transform::AbsolutePosition(spawner), direction);
EntityWrapper ray = SpawnerSystem::Spawn(spawner);
((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f);
glm::vec3& orientation = ray["Transform"]["Orientation"];
orientation.x += angles.x;
orientation.y += angles.y;
glm::vec3 trajectory = direction * distance;
dealDamage(cWeapon, wi, direction, pelletDamage);
}
}
// Play animation // Play animation
playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Fire"); playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Fire");
@@ -245,35 +255,7 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
} }
void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo& wi, std::vector<glm::vec2> pattern) void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage)
{
EntityWrapper muzzle = getRelevantWeaponEntity(wi).FirstChildByName("WeaponMuzzle");
if (!muzzle.Valid()) {
return;
}
float spreadAngle = glm::radians((float)cWeapon["SpreadAngle"]);
for (auto& pellet : pattern) {
glm::quat pelletRotation = glm::quat(Transform::AbsoluteOrientationEuler(wi.Player.FirstChildByName("Camera"))) * glm::quat(glm::vec3(pellet.y, pellet.x, 0) * spreadAngle);
glm::vec3 origin = Transform::AbsolutePosition(wi.Player.FirstChildByName("Camera"));
glm::vec3 direction = pelletRotation * glm::vec3(0, 0, -1);
float distance = traceRayDistance(origin, direction);
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
if (ray.Valid()) {
ComponentWrapper cTransform = ray["Transform"];
glm::vec3& position = cTransform["Position"];
glm::vec3& orientation = cTransform["Orientation"];
glm::vec3& scale = cTransform["Scale"];
position = Transform::AbsolutePosition(wi.Player.FirstChildByName("Camera"));
orientation = glm::eulerAngles(pelletRotation);
scale.z = distance;
}
}
}
void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, const std::vector<glm::vec2>& pattern)
{ {
// Only deal damage client side // Only deal damage client side
if (!IsClient) { if (!IsClient) {
@@ -289,76 +271,47 @@ void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& w
if (!wi.Player.Valid()) { if (!wi.Player.Valid()) {
return; return;
} }
// Convert the spread angle to screen coordinates, taking FOV into account glm::vec3 maxRange = direction * 2.f;
Rectangle res = m_Renderer->GetViewportSize(); EntityWrapper camera = wi.Player.FirstChildByName("Camera");
float spreadAngle = glm::radians((float)cWeapon["SpreadAngle"]); glm::vec3 cameraPosition = Transform::AbsolutePosition(camera);
float nearClip = (double)m_CurrentCamera["Camera"]["NearClip"]; if (!camera.Valid()) {
float farClip = (double)m_CurrentCamera["Camera"]["FarClip"]; return;
float yFOV = glm::radians((double)m_CurrentCamera["Camera"]["FOV"]); }
//float yRefFOV = glm::radians(59.f); Rectangle screenResolution = m_Renderer->GetViewportSize();
//float yRef = glm::tan(yRefFOV) * nearClip; glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2);
//float yRatio = yRef / (glm::tan(yFOV) * nearClip); glm::vec2 screenCoords = cameraFromEntity(m_CurrentCamera).WorldToScreen(cameraPosition + maxRange, m_Renderer->GetViewportSize());
//float yMax = (yRatio / 2.f) * spreadAngle * (res.Height / 2.f); PickData pickData = m_Renderer->Pick(centerScreen + screenCoords);
float yRefFOV = glm::radians(59.f); EntityWrapper victim(m_World, pickData.Entity);
float yRef = glm::tan(yRefFOV) * nearClip; if (!victim.Valid()) {
float yRatio = yRef / (glm::tan(yFOV) * nearClip); return;
float yMax = yRatio * (glm::tan(spreadAngle) * farClip);
LOG_DEBUG("Ratio: %f", yRatio);
LOG_DEBUG("fatClip: %f", farClip);
LOG_DEBUG("yMax: %f", yMax);
double pelletDamage = (double)cWeapon["BaseDamage"] / pattern.size();
// Pick!
std::unordered_map<EntityWrapper, double> damageSum;
glm::vec2 screenCenter(res.Width / 2.f, res.Height / 2.f);
for (auto& pellet : pattern) {
glm::vec2 pickCoord = screenCenter + (pellet * glm::vec2(yMax, yMax));
PickData pick = m_Renderer->Pick(pickCoord);
EntityWrapper victim(m_World, pick.Entity);
if (!victim.Valid()) {
continue;
}
// Temp hit decal
EntityWrapper hit = ResourceManager::Load<EntityFile>("Schema/Entities/HitTest.xml")->MergeInto(m_World);
hit["Transform"]["Position"] = pick.Position;
// Don't let us shoot ourselves in the foot somehow
if (victim == LocalPlayer) {
continue;
}
// Only care about players being hit
if (!victim.HasComponent("Player")) {
victim = victim.FirstParentWithComponent("Player");
if (!victim.Valid()) {
continue;
}
}
// Check for friendly fire
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
// TODO: Ammo sharing
continue;
}
damageSum[victim] += pelletDamage;
((glm::vec3&)hit["Model"]["Color"]).b = 1.f;
} }
// Deal damage! // Don't let us shoot ourselves in the foot somehow
for (auto& kv : damageSum) { if (victim == LocalPlayer) {
// Deal damage! return;
Events::PlayerDamage ePlayerDamage;
ePlayerDamage.Inflictor = wi.Player;
ePlayerDamage.Victim = kv.first;
ePlayerDamage.Damage = kv.second;
m_EventBroker->Publish(ePlayerDamage);
LOG_DEBUG("Dealt %f damage to #%i", kv.second, kv.first.ID);
} }
// Only care about players being hit
if (!victim.HasComponent("Player")) {
victim = victim.FirstParentWithComponent("Player");
}
if (!victim.Valid()) {
return;
}
// Check for friendly fire
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
return;
}
// Deal damage!
Events::PlayerDamage ePlayerDamage;
ePlayerDamage.Inflictor = wi.Player;
ePlayerDamage.Victim = victim;
ePlayerDamage.Damage = damage;
m_EventBroker->Publish(ePlayerDamage);
LOG_DEBUG("Damage: %f", damage);
} }
bool DefenderWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) bool DefenderWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi)