-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/object position dimensions #93
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
Conversation
…SolidSurface` (note: player eye level + rendering and warren bear rendering positions are likely off from their expected locations
…d duplication object position and dimensions)
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.
I'm doing this on my phone while riding the bus, so I'll be able to test on my computer in a bit. I just left the one potential tiny comment which might be nice to have. Also, if we could remove the commented out code that would be nice, so we don't get confused later. I'll drop the approve in a bit once I verify it works on my laptop (which it should but just want to be sure)
Overall this is incredibly helpful! Thanks so much for grinding this out!
src/client/client.cpp
Outdated
auto player_pos = glm::vec3(sharedObject->physics.position.x, sharedObject->physics.position.y + 0.1, sharedObject->physics.position.z); | ||
//auto player_pos = glm::vec3(sharedObject->physics.position.x, sharedObject->physics.position.y + 0.1, sharedObject->physics.position.z); | ||
|
||
auto player_pos = sharedObject->physics.corner + (sharedObject->physics.dimensions / 2.0f); |
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.
Maybe we can make a function on the Physics struct called getCenterPos that does this calculation for us?
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.
Added!
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.
…CollisionSphere()` and `detectCollisionBox()` to ensure correct behavior if the second argument of `detectCollision()` has `Collider::None`
…com/ucsd-cse125-sp24/group3 into refactor/object-position-dimensions
… argument has the expected collider type
…me code that did center position calculation with a call to this method
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.
Looks great. I'm liking this new structure.
Refactored
Object
position + dimensions information to avoid state duplication which required careful syncing of different fields.Here is the new position + dimensions
Object
paradigm:Object
now has aModelType
enum field that specifies the rendering model that thisObject
should render as by the client. (For the DM, this may require settingModelType::None
(which doesn't exist currently) or the client can simply hard-code the behavior that the DM shouldn't be rendered regardless of its specified model type)Collider
field in thePhysics
struct has been replaced: instead of aCollider *
to one of the derivedCollider
classes (BoxCollider
orSphereCollider
), it now has aCollider
enum field which can be eitherBox
orSphere
, with collision detection placed in global functions declared inserver/game/collider.hpp
. This means colliders have no state and utilize theSharedPhysics
fields ofcorner
anddimensions
to detect collisions.position
field inSharedPhysics
has been removed.dimensions
field inSharedSolidSurface
has been removed.The
Object
class now has a new static field:static std::unordered_map<ModelType, glm::vec3> models
which maps theModelType
enum values to their model's default dimensions. Currently, these are all hard-coded inobject.cpp
, but this can be replaced by the server reading the model object files upon initialization and populating this hash map dynamically.Note: The hard-coded dimensions for
ModelType::Player
andModelType::WarrenBear
do NOT currently correspond to the actual model dimensions! Their values are my current guesses as I'm not sure how to extract the models' dimension data. If the player / warren bear do not render properly / in the right positions, this is likely why.Closes #90