Page MenuHome

BGE: Change character jumping to char
ClosedPublic

Authored by Thomas Szepe (hg1) on May 16 2015, 4:38 PM.

Details

Summary
  • Change the character jumping variables and methods from int to char.
  • Limit the maxJumps integer value from 0 to 255.
  • Allow to set the minimum jump amount to 0.

Diff Detail

Repository
rB Blender

Event Timeline

Thomas Szepe (hg1) retitled this revision from to BGE: Change character jumping to char.May 16 2015, 4:38 PM
Thomas Szepe (hg1) updated this object.
Thomas Szepe (hg1) updated this revision to Diff 4241.
source/gameengine/Ketsji/KX_CharacterWrapper.cpp
115

I have forgotten to change the text from "between 1 and 255" to "from 1 to 255".

source/gameengine/Ketsji/KX_CharacterWrapper.cpp
113

I wonder if a value of 0 is useful since we've supported it in the past. I guess it could be used as a quick way to disable jumping from the Python API.

Changes:

  1. Change char to unsigned char.
  2. Silent clamp values from 1 to 255. (Campbell prefer silent clamping)
Porteries Tristan (panzergame) added inline comments.
source/gameengine/Physics/Bullet/CcdPhysicsController.h
431

i think it's better to define this function as constant :

virtual unsigned char GetMaxJumps() const { return getMaxJumps(); }
433

Same here.

Angus Hollands (agoose77) added inline comments.
source/gameengine/Ketsji/KX_CharacterWrapper.cpp
31

Whilst I recognise this might be a quick hack, I think the user code should be responsible for this, not the character wrapper.

Also, shouldn't the PY API enforce unsigned positive, between range?

source/gameengine/Ketsji/KX_CharacterWrapper.cpp
31

I am not 100% sure what you mean here. But I try to answer you, how I think what you want to tell me.

Whilst I recognise this might be a quick hack, I think the user code should be responsible for this, not the character wrapper.

This is an existing API. I can't remove the API without breaking existing code. Also it is necessary to get double jumps working with the LB motion actuator.

Also, shouldn't the PY API enforce unsigned positive, between range?

For converting Python arguments with an integer value, we use PyLong_AsLong which returns a C long representation, with LONG_MAX (2147483647L) as maximum. So we need to manually clamp the range to 255.

source/gameengine/Physics/Bullet/CcdPhysicsController.h
431

Why?

source/gameengine/Ketsji/KX_CharacterWrapper.cpp
31

It was a reply to moguri. However, if it works, it's fine to allow 0, after some more thought.

Thomas Szepe (hg1) updated this revision to Diff 4629.

Change code to get maxJumps working with zero.

Jorge Bernal (lordloki) accepted this revision.

Looks good to me

This revision is now accepted and ready to land.Jul 12 2015, 5:14 PM
Mitchell Stokes (moguri) accepted this revision.

Making some of these member functions constant would probably be nice, but that would be better done in a separate patch.

This revision was automatically updated to reflect the committed changes.