Files
vgstation13/code/modules/unit_tests/vector.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

58 lines
1.4 KiB
Plaintext

/datum/unit_test/vector_duplicate/start()
var/vector/V
var/vector/D
for(var/i in range(100))
V = new /vector(i, i*2)
D = V.duplicate()
if(D == V)
fail("Reference copied")
if(D.x != V.x || D.y != V.y)
fail("Value mismatch")
/datum/unit_test/vector_isnull/start()
var/vector/V = new /vector(0,0.0)
if(!V.is_null())
fail("Vector not null")
/datum/unit_test/vector_isint/start()
var/vector/V = new /vector(5416,115)
if(!V.is_integer())
fail("Vector not int, should be int")
V = new /vector(5416.044,115)
if(V.is_integer())
fail("Vector int, should not be int")
/datum/unit_test/vector_toangle/start()
var/vector/V = new /vector(1,1)
var/angle = V.toAngle()
if(angle != 45)
fail("Angle #1 ("+num2text(angle)+") incorrect")
V = new /vector(-1,1)
angle = V.toAngle()
if(angle != 315)
fail("Angle #2 ("+num2text(angle)+") incorrect")
/datum/unit_test/vector_mirror/start()
var/vector/V = new /vector(1,-1)
var/vector/N = new /vector(0,1)
var/vector/M = new /vector(1,1)
var/vector/R = V.mirrorWithNormal(N)
if(!R.equals(M))
fail("Mirror #2 incorrect "+R.toString())
/datum/unit_test/vector_dot/start()
var/vector/V1 = new /vector(4,-1)
var/vector/V2 = new /vector(1,1)
var/d = V1.dot(V2)
if(d != 3)
fail("Dot product #1 ("+num2text(d)+") incorrect")
V1 = new /vector(0,2)
V2 = new /vector(1,1)
d = V1.dot(V2)
if(d != 2)
fail("Dot product #2 ("+num2text(d)+") incorrect")