Skip to content
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

UPBGE: Fix compound ray cast with triangle child shape. #766

Open
wants to merge 391 commits into
base: master
Choose a base branch
from

Conversation

panzergame
Copy link
Contributor

Previously when a compound shape was hit by a ray cast the information about
the children triangles was inaccessible because of a lack from the bullet
API.

To fix this issue we have to keep the triangle index but add a child index
of the compound child shape hit. m_childIndex is dedicated for in LocalRayResult
and its value is set in rayTestSingleInternal, -1 for non compound shapes.

This value is catch from FilterClosestRayResultCallback and used in RayTest
to get the actual collision shape. To still get the shape construction info
of the children, each collision shape created has as user pointer the
shape costruction info. This object is get in RayTest to find the mesh
and polygon.

Tested with:

  • mix of convex and concave shape in a compound shape.
  • non compound concave and convex shape.

Example file:
ge_compound.zip
The hit polygon color is set to red. The compound shape is made of two triangle mesh (concave) and a box (convex), the fourth object is a non-compound triangle mesh (concave).

panzergame and others added 30 commits October 14, 2017 18:38
Member functions are cheaper to call than std::function.
ReplaceMesh function was placed into KX_Scene for no real reason, its
place is more correct into KX_GameObject directly. In the same time the
code part reinstancing the deformers is moved in a new function named
LoadDeformer in class BL_DeformableObject. This funciton is also used by
the converter to init deformes after the parenting step (for armatures).
This uniform is frequently changed between the viewport settings and
in game settings, to avoid recompiling the materials only for it
and has this uniform is a more a flag than a value: this uniform
back to dynamic uniform.

Fix issue: #609.
Previously the code parts computing AABB were using a condition
to detect the first point computed used to initialize the AABB
dimensions. But this method requiered a test at each points and
also to be able to detect the first point.
To avoid these restrictions the AABB dimension is initialized to
float min for max and float max for min. This make sure that any
point will affect the AABB the first time.
THe deformer conversion have some extra constraint, first it had to be placed
before the RAS_MeshUser are created with AddMeshUser, secondly BL_ShapeDeformer
have to check the case when parent object is null.

Also the function BL_SkinDeformer::SetArmature became useless and the construtors
in deformers in case of conversion of non-replicated object are removed because
unused anymore.
The call to ConvertScene wasn't taking care if the scene existed
because it's name was valid. This function call is moved down
in a if block.

Fix issue: #615.
This cleanup contains a uncrusty pass.
Previously the servo control logic brick was able to control only
the linear velocity using force. But some users showed that in some
non-rare case it could be needed to servo control the angular velocity
via torques.

To fill this gap, the servo control logic brick exposes a enum named
"Servo Type" to select either linear or angular velocity, linear is
the default. This option is used in KX_ObjectActuator to compute
from linear or angular velocity a force or torque.

Note: The reference object in case of angular velocity is just used to
substract its angular velocity contrary to linear velocity which compute
the linear velocity of the reference object on the position of the affected
object.
This cleanup contains:
- uncrustify pass
- use range loop
- remove friend class
Previously the inexistance of a python component manager forced
in KX_Scene to iterate over all the object to ask for a component
update. The implementation of a manager with a registering
mechanism help to avoid this iteration and optimize as much as
possible the case where a scene doesn't update any components.
…::GetChildren.

The functions GetChildren and GetChildrenRecursive were not used only for
the python API but also for the animation and duplication process, in these
last cases the creation of a std::vector is cheaper and more easy to use.
For the python API prupose, EXP_ListValue now had a constructor taking
a std::vector to copy items from.
The properties in EXP_Value now use a std::map value instead of a
pointer to std::map, the economy is pretty low with a pointer.
The m_error flag is removed in favor of a virtual function IsError
redefined in EXP_ErrorValue to return true.
Previously the vertex remap was resized with default value to -1 but if
this list wasn't empty the previous value were kept. To initialize all
values to -1 std::fill is used.

Fix issue: #622.
Two functions are added to replace frequently used behaviour:
remove if an element is found in a list, or add if an element is
not present in a list. The functions CM_ListRemoveIfFound
and CM_ListAddIfNotFound assume these goal, they are defined in
new file CM_List.h.
panzergame and others added 18 commits August 5, 2018 11:46
* UPBGE: Implement new Lamp Falloff

- Inverse Square Cutoff for Lamps. Describes here:
https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/

Original code by @DCubix. Slightly modified by me to add light preview.

New Radius & CutOff parameters exposed in UI when you select "Inverse Square CutOff" falloff type in point and spot lamps

For feature request #728
All texts are using a unique material per scene and so a unique
material bucket and display array bucket. They both are owned
by the bucket manager (RAS_BucketManager). In case of libload
all the material buckets of the loaded scene are moved into the
destination scene bucket manager.

In case of text material the material bucket of the loaded was
moved but also destructed when the loaded was freed at the end
of the libload, this created an illegal memory access.

To solve this issue, the only proper way found is to discard
the material bucket dedicated to text when mergin the bucket
manager and when merging the objects, for font objects force
the recreation of the text user (RAS_TextUser) to be sure that
this one is linked to the display array bucket for texts of the
destination scene.

Tested with valgrind.
Previously it was a float array but some code is converting it
back to mt::mat4. As mt::mat4 has a direct array acces the cost
is the same as a float array.
Workaround for weird MSVC2015 compiler
The assertion in Mathutils_RegisterCallback was raised when all the callbacks
were registered (freestyle and bmesh too).
But this assertion introduced in 1b74ec9 is wrong. The test i + 1 < MAX
suppose that the last callback is a null sentinel. But this is not the
case as no one is using this to stop a loop and the loop in
Mathutils_RegisterCallback must stop when it find a null slot or that the
slot is already containing the callback, otherwise it's an error.
It's impossible to stop the loop with all regular slots registered and
and different from the one intenting to register.

Fix a part of issue #785.
gl_Color is set as the vertex color of the first color layer,
this was broken by the addressu sage of RAS_DisplayArrayLayout::colors
instead of RAS_DisplayArrayLayout::colors[0].

Fix issue #784.
These's modifications were pulled for unknown reason, sorry…
In the interest of futur way to start a game from a memory file,
the exit information should not track only the file name but also
more data.

To do so the exit informations are standardized into the struct
KX_ExitInfo which holds the exit code and the file name for the
moment. This struct is stored into the ketsji engine and returned
by KX_KetsjiEngine::GetExitInfo.

Inside LA_Launcher::EngineNextFrame an exit code can be generated
(only for window exit or exit key) and the exit info is returned.
This same exit info is checked in LA_Launcher::EngineMainLoop
when it contains a exit code different from NO_REQUESTS this function
returns and so abort the launcher. Finally the creator of the
launcher is using this exit info in case or restart or start to get
the file name.

In the same time the restoration of cursor visibility is moved into
GPG_ghost and BL_KetsjiEmbedStart instead of the launcher.
panzergame and others added 4 commits August 16, 2018 14:16
The function SetCullFace now use a state from RAS_Rasterizer to skip
unecessary opengl calls. Also the rendering of plane to screen is now
using the function SetFrontFace instead disabling and renabling the
face culling.
The shader used to blur a texture was using ftransform for gl_Position
and so it needed the modelview/prjection matrix to be set.
This can be avoided by using gl_Vertex directly.
The python main loop is using PythonMainLoopState struct to get the launcher
and set the exit info, but the launcher wasn't set.
Previously when a compound shape was hit by a ray cast the information about
the children triangles was inaccessible because of a lack from the bullet
API.

To fix this issue we have to keep the triangle index but add a child index
of the compound child shape hit. m_childIndex is dedicated for in LocalRayResult
and its value is set in rayTestSingleInternal, -1 for non compound shapes.

This value is catch from FilterClosestRayResultCallback and used in RayTest
to get the actual collision shape. To still get the shape construction info
of the children, each collision shape created has as user pointer the
shape costruction info. This object is get in RayTest to find the mesh
and polygon.

Tested with:
- mix of convex and concave shape in a compound shape.
- non compound concave and convex shape.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.