-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial Vector Performant Calculation
Kamran Wali edited this page Nov 27, 2024
·
2 revisions
I have also added performant Vector calculations that may save some performance issue in the long run especially when it comes to Vector distance calculation. The class is called Vec and it contains static functions. I will give just brief explanation of the functions.
- float distance_vec3( Vector3 value1, Vector3 value2 ) - This method calculates the distance between two Vector3s and the returned value is a squared value. This means that if you want to check if the distance of the two vector point is greater/less than 5 units then you must make 5 squared which is simply 5x5 = 25. Meaning you are comparing against 25. This will save lot of performance issue later down the line when too many objects needs distance check.
- float distance_fixed_vec3_var( COP_FixedVector3Var value1, COP_FixedVector3Var value2 ) - This method is similar to 1. so please read that description for explanation. Only difference is that it takes two COP_FixedVector3Vars.
- float distance_vec3_var( COP_Vector3Var value1, COP_Vector3Var value2 ) - This method is similar to 1. so please read that description for explanation. Only difference is that it takes two COP_Vector3Vars.
- float distance_vec2( Vector2 value1, Vector2 value2 ) - This method is similar to 1. so please read that description for explanation. Only difference is that it takes two Vector2s.
- float distance_fixed_vec2_var( COP_FixedVector2Var value1, COP_FixedVector2Var value2 ) - This method is similar to 1. so please read that description for explanation. Only difference is that it takes two COP_FixedVector2Vars.
- float distance_vec2_var( COP_Vector2Var value1, COP_Vector2Var value2 ) - This method is similar to 1. so please read that description for explanation. Only difference is that it takes two COP_Vector2Vars.
- Vector3 subtract_vec3(Vector3 value1, Vector3 value2) - This method subtracts two Vector3 without needing any extra var variable and returns a Vector3 value.
- Vector3 subtract_fixed_vec3_var( COP_FixedVector3Var value1, COP_FixedVector3Var value2 ) - This method is similar to 7. so please read that description for explanation. The only difference is that it takes two COP_FixedVector3Vars.
- Vector3 subtract_vec3_var(COP_Vector3Var value1, COP_Vector3Var value2) - This method is similar to 7. so please read that description for explanation. The only difference is that it takes two COP_Vector3Vars.
- Vector2 subtract_vec2(Vector2 value1, Vector2 value2) - This method subtracts two Vector2 without needing any extra var variable and returns a Vector2 value.
- Vector2 subtract_fixed_vec2_var(COP_FixedVector2Var value1, COP_FixedVector2Var value2) - This method is similar to 10. so please read that description for explanation. The only difference is that it takes two COP_FixedVector2Vars.
- Vector2 subtract_vec2_var(COP_Vector2Var value1, COP_Vector2Var value2) - This method is similar to 10. so please read that description for explanation. The only difference is that it takes two COP_Vector2Vars.
- Vector3 add_vec3(Vector3 value1, Vector3 value2) - This method adds two Vector3s without needing any extra var variable and returns a Vector3 value.
- Vector3 add_fixed_vec3_var(COP_FixedVector3Var value1, COP_FixedVector3Var value2) - This method is similar to 13. so please read that description for explanation. The only difference is that it takes two COP_FixedVector3Vars.
- Vector3 add_vec3_var( COP_Vector3Var value1, COP_Vector3Var value2 ) - This method is similar to 13 so please read that description for explanation. The only difference is that it takes two COP_Vector3Vars.
- Vector2 add_vec2( Vector2 value1, Vector2 value2 ) - This method adds two Vector2s without needing any extra var variable and returns a Vector2 value.
- Vector2 add_fixed_vec2_var(COP_FixedVector2Var value1, COP_FixedVector2Var value2) - This method is similar to 16. so please read that description for explanation. The only difference is that it takes two COP_FixedVector2Var.
- Vector2 add_vec2_var( COP_Vector2Var value1, COP_Vector2Var value2 ) - This method is similar to 16. so please read that description for explanation. The only difference is that it takes two COP_Vector2Vars.
- Vector3 divide_vec3( Vector3 vector, float value ) - This method divides the Vector3 value with the float value without needing any extra var variable and returns a Vector3.
- Vector3 divide_fixed_vec3_var( COP_FixedVector3Var vector, float value ) - This method is similar to 19. so please read that description for explanation. The only difference is that it takes COP_FixedVector3Var.
- Vector3 divide_vec3_var(COP_Vector3Var vector, float value) - This method is similar to 19. so please read that description for explanation. The only difference is that it takes COP_Vector3Var.
- Vector2 divide_vec2( Vector2 vector, float value ) - This method divides the Vector2 value with the float value without needing any extra var variable and returns a Vector2.
- Vector2 divide_fixed_vec2_var(COP_FixedVector2Var vector, float value) - This method is similar to 22. so please read that description for explanation. The only difference is that it takes COP_FixedVector2Var.
- Vector2 divide_vec2_var( COP_Vector2Var vector, float value ) - This method is similar to 22. so please read that description for explanation. The only difference is that it takes COP_Vector2Var.
- Vector3 multiply_vec3( Vector3 vector, float value ) - This method multiplys the Vector3 value with the float value without needing any extra var variable and returns a Vector3.
- Vector3 multiply_fixed_vec3_var( COP_FixedVector3Var vector, float value ) - This method is similar to 25. so please read that description for explanation. The only difference is that it takes COP_FixedVector3Var.
- Vector3 multiply_vec3_var( COP_Vector3Var vector, float value ) - This method is similar to 25. so please read that description for explanation. The only difference is that it takes COP_Vector3Var.
- Vector2 multiply_vec2( Vector2 vector, float value ) - This method multiplys the Vector2 value with the float value without needing any extra var variable and returns a Vector2.
- Vector2 multiply_fixed_vec2_var(COP_FixedVector2Var vector, float value) - This method is similar to 28. so please read that description for explanation. The only difference is that it takes COP_FixedVector2Var.
- Vector2 multiply_vec2_var( COP_Vector2Var vector, float value ) - This method is similar to 28. so please read that description for explanation. The only difference is that it takes COP_Vector2Var.
- Vector3 set_vec3_f(Vector3 vector, float x, float y, float z) - This method sets the target Vector3 axis values with the provided float values. It then returns the Vector3 without needing any extra var variables.
- Vector2 set_vec2_f(Vector2 vector, float x, float y, float z) - This method sets the target Vector2 axis values with the provided float values. It then returns the Vector2 without needing any extra var variables.
- Tutorial Bar
- Tutorial Debug
- Tutorial Instantiate Object
- Tutorial Pool
- Tutorial Timer
- Tutorial Update Manager
- Tutorial Variable Creator
- Bars
- Debugs
- Maths
- Pools
- Resources
- Fixed Vars
- Managers
- Observers
- Vars
- Script Templates
- Timers
- Updates