more fun
This commit is contained in:
parent
f0b1ed2fca
commit
a5d1129f0e
6 changed files with 512 additions and 112 deletions
|
|
@ -145,7 +145,8 @@ void DynamicMover::Create( b3WorldId worldId, const DynamicMoverDef* def )
|
|||
b3ShapeDef shapeDef = b3DefaultShapeDef();
|
||||
shapeDef.density = def->density;
|
||||
|
||||
// The mover joint and the pogo joint handle all the movement, surface friction would fight them
|
||||
// The mover joint and the pogo joint handle all the movement, surface friction would fight
|
||||
// them.
|
||||
shapeDef.baseMaterial.friction = 0.0f;
|
||||
shapeDef.baseMaterial.restitution = 0.0f;
|
||||
shapeDef.filter = def->filter;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "box3d/collision.h"
|
||||
#include "box3d/types.h"
|
||||
|
||||
struct DynamicMoverDef
|
||||
|
|
@ -11,7 +10,6 @@ struct DynamicMoverDef
|
|||
b3Pos position = {};
|
||||
b3Capsule capsule = { { 0.0f, -0.5f, 0.0f }, { 0.0f, 0.5f, 0.0f }, 0.3f };
|
||||
|
||||
// About 80 kilograms for the default capsule
|
||||
float density = 200.0f;
|
||||
|
||||
b3Filter filter = b3DefaultFilter();
|
||||
|
|
@ -20,7 +18,7 @@ struct DynamicMoverDef
|
|||
float minSpeed = 0.1f;
|
||||
float stopSpeed = 3.0f;
|
||||
float accelerate = 20.0f;
|
||||
float airSteer = 0.5f;
|
||||
float airSteer = 0.25f;
|
||||
float friction = 8.0f;
|
||||
float gravityScale = 1.5f;
|
||||
float maxGroundForce = 6000.0f;
|
||||
|
|
@ -85,6 +83,11 @@ public:
|
|||
// Gravity scale is used to size the pogo forces, so change it here.
|
||||
void SetGravityScale( float gravityScale );
|
||||
|
||||
b3BodyId GetBodyId() const
|
||||
{
|
||||
return m_moverId;
|
||||
}
|
||||
|
||||
void Draw() const;
|
||||
|
||||
static constexpr int m_skirtCount = 8;
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ typedef struct
|
|||
bool transparentDynamic;
|
||||
bool transparentKinematic;
|
||||
|
||||
// One body drawn with reduced alpha, such as a character the camera is close to
|
||||
b3BodyId alphaBodyId;
|
||||
float bodyAlpha;
|
||||
|
||||
// View box for compound child culling, world space, refreshed once per frame.
|
||||
b3AABB viewBounds;
|
||||
bool hasViewBounds;
|
||||
|
|
@ -158,6 +162,8 @@ void InitAdapter( void )
|
|||
s_adapter.selectedShapeId = b3_nullShapeId;
|
||||
s_adapter.transparentDynamic = false;
|
||||
s_adapter.transparentKinematic = false;
|
||||
s_adapter.alphaBodyId = b3_nullBodyId;
|
||||
s_adapter.bodyAlpha = 1.0f;
|
||||
|
||||
s_adapter.hasViewBounds = false;
|
||||
s_adapter.lastCompoundAppended = 0;
|
||||
|
|
@ -197,6 +203,8 @@ void ResetAdapterPool( void )
|
|||
s_adapter.selectedShapeId = b3_nullShapeId;
|
||||
s_adapter.transparentDynamic = false;
|
||||
s_adapter.transparentKinematic = false;
|
||||
s_adapter.alphaBodyId = b3_nullBodyId;
|
||||
s_adapter.bodyAlpha = 1.0f;
|
||||
|
||||
s_adapter.hasViewBounds = false;
|
||||
s_adapter.lastCompoundAppended = 0;
|
||||
|
|
@ -239,6 +247,12 @@ void SetTransparentKinematic( bool enabled )
|
|||
s_adapter.transparentKinematic = enabled;
|
||||
}
|
||||
|
||||
void SetBodyAlpha( b3BodyId bodyId, float alpha )
|
||||
{
|
||||
s_adapter.alphaBodyId = bodyId;
|
||||
s_adapter.bodyAlpha = alpha;
|
||||
}
|
||||
|
||||
void SetViewBounds( b3AABB bounds )
|
||||
{
|
||||
s_adapter.viewBounds = bounds;
|
||||
|
|
@ -862,6 +876,11 @@ static void DrawShape( void* userShape, b3WorldTransform shapeTransform, b3HexCo
|
|||
c.w = BOX3D_TRANSPARENT_ALPHA;
|
||||
}
|
||||
|
||||
if ( s_adapter.bodyAlpha < 1.0f && B3_ID_EQUALS( us->bodyId, s_adapter.alphaBodyId ) )
|
||||
{
|
||||
c.w = b3MinFloat( c.w, s_adapter.bodyAlpha );
|
||||
}
|
||||
|
||||
if ( s_adapter.transparentKinematic && us->bodyType == b3_kinematicBody )
|
||||
{
|
||||
c.w = BOX3D_TRANSPARENT_ALPHA;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ void SetGroundShape( b3ShapeId shapeId );
|
|||
void SetShapeMaterial( b3ShapeId shapeId, Vec4 color, float metallic, float roughness );
|
||||
void SetTransparentDynamic( bool enabled );
|
||||
void SetTransparentKinematic( bool enabled );
|
||||
void SetBodyAlpha( b3BodyId bodyId, float alpha );
|
||||
|
||||
// View box for compound child culling, world space. Set once per frame before
|
||||
// b3World_Draw. A compound then submits only the children overlapping this box
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -646,6 +646,7 @@ static void b3CollideTask( int startIndex, int endIndex, int workerIndex, void*
|
|||
b3WorldTransform transformA = bodySimA->transform;
|
||||
b3WorldTransform transformB = bodySimB->transform;
|
||||
|
||||
// This is really just needed for mesh collision to prevent tunneling.
|
||||
bool isFast = ( ( bodySimA->flags | bodySimB->flags ) & b3_isFast ) != 0;
|
||||
|
||||
float recycleTolerance = wasTouching ? recycleDistance : recycleDistanceNonTouching;
|
||||
|
|
@ -743,7 +744,8 @@ static void b3CollideTask( int startIndex, int endIndex, int workerIndex, void*
|
|||
contact->flags |= b3_relativeTransformValid;
|
||||
|
||||
// This updates solid contacts
|
||||
bool touching = b3UpdateContact( world, workerIndex, contact, shapeA, bodySimA->localCenter, transformA, shapeB,
|
||||
bool touching = b3UpdateContact( world, workerIndex, contact, shapeA, bodySimA->localCenter,
|
||||
transformA, shapeB,
|
||||
bodySimB->localCenter, transformB, isFast, taskContext->arena );
|
||||
|
||||
int bucketIndex = b3MinInt( contact->manifoldCount, B3_CONTACT_MANIFOLD_COUNT_BUCKETS - 1 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue