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

Editing collisions #730

Open
wants to merge 37 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@CrosRoad95
Copy link
Collaborator

CrosRoad95 commented Dec 17, 2018

Idea of this pr is lets user edit collision.
If you wanna edit collision, load it via engineLoadCOL, original collision you can read by model id, but are read-only.

Examples:
https://www.youtube.com/watch?v=MtlTJ3GxQ-M
https://www.youtube.com/watch?v=_QV2FkASLas
https://www.youtube.com/watch?v=wCCijVBLPjU
https://www.youtube.com/watch?v=m6gVWZVVj3E
https://www.youtube.com/watch?v=Rt82oFuJ-dM

Test resource:
test.zip

Functions

table engineGetModelCollisionProperties( col theCol / int modelID)
table engineGetModelCollisionData( col theCol / int modelID, collision-shape [, int index ] )
bool,table engineSetModelCollisionData( col theCol, collision-shape, collision-key, int shapeID / table shapeID, mixed value )
bool engineUpdateModelCollisionBoundingBox( col theCol [, float x, float y, float z ] )
bool isModelCollisionLoaded( int modelID )

engineGetModelCollisionProperties

Return table with information about loaded .col file or modelID ( if collision is loadeded )

  • boundingBox
    • vecMin {x,y,z} - minimal position of collision
    • vecMax {x,y,z} - maximal position of collision
    • vecOffset {x,y,z} - offset of sphere
    • radius float - radius of bounding sphere
  • colBoxes int - number of boxes that collision has
  • colSpheres int - number of spheres that collision has
  • colTriangles int - number of triangles that collision has
  • colVertices int - number of vertices that collision has

isModelCollisionLoaded

Checks whether original collision is loaded and can be read.

engineSetModelCollisionData

Changing collision, returns boolean if success, and false if something wrong, second argument returns all wrong triangles, vertices etc.

engineUpdateModelCollisionBoundingBox

Updates collision bounding box, need to be used if

  • Collision shape was move outside current bounding box, otherwise your collision had issues with detection peds, vehicles, other elements collisions
  • If you moved collision shape and now bounding box is too big, otherwise gta will needlessly check collision, what unnecessary consume cpu.

Enums

collision-shape: vertex box triangle sphere
collision-key: size material position radius lighting vertices move
vertex arg1 arg2 arg3 description Restrictions
position float float float Changs a position of vertex. abs( position ) <= 128
move float float float Adds a position to a current position. abs( position + move ) <= 128
triangle arg1 arg2 arg3 description Restrictions
material int Changes a material of surface. 0 - 178
lighting int day int night Changes a lighting of triangle. 0 - 15
sphere arg1 arg2 arg3 Description Restrictions
position float float float Changs a position of vertex. abs( position + radius ) <= 128
move float float float Adds a position to a current position. abs( position + move + radius ) <= 128
radius float Changes radius of sphere radius > 0, radius <= 256
material int Changes material of surface. 0 - 178
box arg1 arg2 arg3 arg4 arg5 arg6 Description Restrictions
material int Changes material of surface. 0 - 178
position float float float Changes position of box. abs( position + (maxSize - minSize) / 2 ) <= 128
size boolean float float float Changes size, argument1 == true for min size, false = max size abs( position ) <= 128, max size >= min size
size float float float float float float Changes min and max size. max size >= min size

CrosRoad95 added some commits May 30, 2018

creating triangle
for now, a bit unstable
removing collision boxes
only boxes for now
@gatno

This comment has been minimized.

Copy link

gatno commented Dec 17, 2018

awesome!

@Shaviq

This comment has been minimized.

Copy link

Shaviq commented Dec 17, 2018

Incredible!

@CodyJL

This comment has been minimized.

Copy link

CodyJL commented Dec 17, 2018

Would it be a possible to do a per object collision?

@CrosRoad95

This comment has been minimized.

Copy link
Collaborator

CrosRoad95 commented Dec 17, 2018

Saml1er want do this

@CrosRoad95 CrosRoad95 requested a review from botder Jan 10, 2019

@qaisjp
Copy link
Member

qaisjp left a comment

Please revert changes to vendor/lua.

The reasoning for this is explained in Programming in Lua §24.2 "The Stack".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment