Skip to content

Commit

Permalink
refactor: replace manual position calculation with getPosition method…
Browse files Browse the repository at this point in the history
… in hit functions
  • Loading branch information
LittleTheFu committed Jan 10, 2025
1 parent 2f52a50 commit 0d8da57
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion geometry/ball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool Ball::hit(const Ray &ray, HitRecord &record) const

record.transform = m_transform;

const Vector3 localPoint = newRay.origin + record.t * newRay.dir;
const Vector3 localPoint = newRay.getPosition(record.t);
record.point = m_transform.transformPoint(localPoint);
record.localPoint = localPoint;

Expand Down
2 changes: 1 addition & 1 deletion geometry/plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool Plane::hit(const Ray &ray, HitRecord &record) const
return false;

//refactor later...
Vector3 localPoint = newRay.origin + record.t * newRay.dir;
Vector3 localPoint = newRay.getPosition(record.t);
Vector3 localNormal = Common::LOCAL_NORMAL;

//refactor later...
Expand Down
2 changes: 1 addition & 1 deletion geometry/tri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool Tri::hit(const Ray &ray, HitRecord &record) const
return false;

//reduntant code,refactor later...
Vector3 localPoint = localRay.origin + record.t * localRay.dir;
Vector3 localPoint = localRay.getPosition(record.t);
Vector3 _objPoint = frame.pointToWorld(localPoint);

Vector3 pixelNormal = getWeightedNormal(_objPoint);
Expand Down

0 comments on commit 0d8da57

Please sign in to comment.