Files
vgstation13/code/modules/unit_tests/ray.dm
Paul Ritter f471180f03 Laser rework and Raycasting stuff (#27406)
* basic rays

* vector3 tostring

* hotfix to exclude origin

* altered test method

* vector3 minus

* actually made raycasthits usable

* using raycasthits

* renamed test procs file

* ups

* moved code

* forgot

* moved vector & procs

* reworked 2d-vectors
reworked rays to work with 2d-vectors
optimized raycast algorithm

* reworked raycasting to be costumizable

* reworked beams to use ray - first experiment

* reworked raycasting to enable control of loop over raycast_hit_check

* readability

* reworked beams to use new rays
TODO:
- beam/rebound
- ray/is_point
- test

* vector to angle

* progress - TODO angle calculations

* progress on rebound

* hi damian

* fix oops

* ray hotfixes
TODO:
- use clickpos as ray target if possible
- move rebound logic to ray_hit_check
- graphics

* hotfix & deletions

* added costum hit_type capability
reworked rebound call logic
TODO:
rebound vector calculation

* rebound fix

* angle & mirror fix

* dumb fuck sadasfhgdasd

* start to remove debugging spam

* reflection now fully implemented

* started work on visualization

* damian wants to see

* almost done ™️

* progress report
- turn wont work, need to write render logic to generate beams

* reeeflections

* added drawing code

* - small tweaks
- removed old code
- finished visualization

* added spawn to let different reflections be drawn independent from each other

* removed hitlers

* oh shit oh fuck

* some small fixes

* yeah ok i goofed travis get over it

* made dependant code work

* dumbfire implemented but not tested cause how

* example

* remove bench stuff oops

* rewrote raycast hit code to allow more possible modifications

* added original check

* original_check hotfixes

* actual hotfix...

* mirror fix

* original_check hotfix

* unit tests

* to_bump hotfix

* to_bump hotfix

* misc fixes

* reworked collision physics

* big nono

* finishing collision physics

* fixes for sonix

* tgstation ™️

* removed old unit-test

* unit test fixes

* damian actually reviewed

Co-authored-by: Damian <damian@autistici.org>
2020-08-23 20:13:42 +02:00

39 lines
1.2 KiB
Plaintext

/datum/unit_test/ray_equals/start()
var/vector/origin = new /vector(0,3)
var/vector/direction = new /vector(4,7)
var/ray/R1 = new /ray(origin, direction)
var/ray/R2 = new /ray(origin, direction)
if(!R1.equals(R2))
fail("Rays not equal")
/datum/unit_test/ray_overlaps/start()
var/vector/origin = new /vector(0,3)
var/vector/direction = new /vector(4,7)
var/ray/R1 = new /ray(origin, direction)
var/ray/R2 = new /ray(origin, direction)
if(!R1.overlaps(R2))
fail("Rays #1 not overlapping")
direction = new /vector(-4,-7)
R1 = new /ray(origin, direction)
R2 = new /ray(origin, direction)
if(!R1.equals(R2))
fail("Rays #2 not overlapping")
/datum/unit_test/ray_hitsPoint/start()
var/vector/origin = new /vector(0,3)
var/vector/direction = new /vector(2,10)
var/vector/P = new /vector(1,8)
var/ray/R = new /ray(origin, direction)
if(!R.hitsPoint(P))
fail("Ray not hitting point")
/datum/unit_test/ray_getPoint/start()
var/vector/origin = new /vector(0,3)
var/vector/direction = new /vector(4,10)
var/distance = 0.5
var/vector/P = new /vector(0.2,3.5)
var/ray/R = new /ray(origin, direction)
if(!R.getPoint(distance).equals(P))
fail("Ray returned invalid point "+R.getPoint(distance).toString())