-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Collisions module and rotate to velocity
- Loading branch information
Showing
34 changed files
with
599 additions
and
157 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "Collisions.h" | ||
|
||
namespace Effekseer | ||
{ | ||
|
||
void CollisionsParameter::Load(unsigned char*& pos, int version) | ||
{ | ||
if (version >= Version18Alpha1) | ||
{ | ||
int isEnabled = 0; | ||
memcpy(&isEnabled, pos, sizeof(int)); | ||
pos += sizeof(int); | ||
|
||
IsEnabled = isEnabled > 0; | ||
|
||
memcpy(&Bounce, pos, sizeof(float)); | ||
pos += sizeof(float); | ||
|
||
memcpy(&Height, pos, sizeof(float)); | ||
pos += sizeof(float); | ||
|
||
memcpy(&WorldCoordinateSyatem, pos, sizeof(int)); | ||
pos += sizeof(int); | ||
} | ||
} | ||
|
||
std::tuple<SIMD::Vec3f, SIMD::Vec3f> CollisionsFunctions::Update( | ||
CollisionsState& state, | ||
const CollisionsParameter& parameter, | ||
const SIMD::Vec3f& next_position_global, | ||
const SIMD::Vec3f& position_global, | ||
const SIMD::Vec3f& velocity_global, | ||
const SIMD::Vec3f& position_center_local) | ||
{ | ||
if (!parameter.IsEnabled) | ||
{ | ||
return { | ||
SIMD::Vec3f(0, 0, 0), SIMD::Vec3f(0, 0, 0)}; | ||
} | ||
|
||
auto next_position = next_position_global; | ||
auto current_position = position_global; | ||
|
||
if (parameter.WorldCoordinateSyatem == WorldCoordinateSyatemType::Local) | ||
{ | ||
next_position -= position_center_local; | ||
current_position -= position_center_local; | ||
} | ||
|
||
if (next_position.GetY() < parameter.Height && current_position.GetY() >= parameter.Height) | ||
{ | ||
auto diff = next_position - current_position; | ||
auto pos_diff = diff * (current_position.GetY() - parameter.Height) / diff.GetY(); | ||
return {SIMD::Vec3f(0, -velocity_global.GetY() * (1.0f + parameter.Bounce), 0), pos_diff}; | ||
} | ||
else | ||
{ | ||
return { | ||
SIMD::Vec3f(0, 0, 0), SIMD::Vec3f(0, 0, 0)}; | ||
} | ||
} | ||
|
||
} // namespace Effekseer |
Oops, something went wrong.