bring across lua raycast improvements from 1.x
Signed-off-by: greerdv <greerdv@amazon.com>
This commit is contained in:
@@ -34,6 +34,28 @@ namespace AzPhysics
|
||||
const CollisionGroup CollisionGroup::All_NoTouchBend = CollisionGroup::All.GetMask() & ~CollisionLayer::TouchBend.GetMask();
|
||||
#endif
|
||||
|
||||
void CollisionGroupScriptConstructor(CollisionGroup* thisPtr, AZ::ScriptDataContext& scriptDataContext)
|
||||
{
|
||||
int numArgs = scriptDataContext.GetNumArguments();
|
||||
if (numArgs != 1)
|
||||
{
|
||||
scriptDataContext.GetScriptContext()->Error(AZ::ScriptContext::ErrorType::Error, true,
|
||||
"CollisionGroup() accepts only 1 argument, not %d", numArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!scriptDataContext.IsString(0))
|
||||
{
|
||||
scriptDataContext.GetScriptContext()->Error(AZ::ScriptContext::ErrorType::Error, true,
|
||||
"Argument to CollisionGroup() should be string");
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::string groupName;
|
||||
scriptDataContext.ReadArg(0, groupName);
|
||||
*thisPtr = CollisionGroup(groupName);
|
||||
}
|
||||
|
||||
void CollisionGroup::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
@@ -50,7 +72,9 @@ namespace AzPhysics
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||
->Attribute(AZ::Script::Attributes::Category, "AzPhysics")
|
||||
->Constructor<const AZStd::string>()
|
||||
->Constructor<const AZStd::string&>()
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
|
||||
->Attribute(AZ::Script::Attributes::ConstructorOverride, &CollisionGroupScriptConstructor)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,19 @@ namespace AzPhysics
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto* behaviorContext = azdynamic_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<SceneQueryRequest>("SceneQueryRequest")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||
->Attribute(AZ::Script::Attributes::Category, "PhysX")
|
||||
->Property("Collision", BehaviorValueProperty(&SceneQueryRequest::m_collisionGroup))
|
||||
// Until enum class support for behavior context is done, expose this as an int
|
||||
->Property("QueryType", [](const SceneQueryRequest& self) { return static_cast<int>(self.m_queryType); },
|
||||
[](SceneQueryRequest& self, int newQueryType) { self.m_queryType = SceneQuery::QueryType(newQueryType); })
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void RayCastRequest::Reflect(AZ::ReflectContext* context)
|
||||
@@ -123,10 +136,6 @@ namespace AzPhysics
|
||||
->Property("Distance", BehaviorValueProperty(&RayCastRequest::m_distance))
|
||||
->Property("Start", BehaviorValueProperty(&RayCastRequest::m_start))
|
||||
->Property("Direction", BehaviorValueProperty(&RayCastRequest::m_direction))
|
||||
->Property("Collision", BehaviorValueProperty(&RayCastRequest::m_collisionGroup))
|
||||
// Until enum class support for behavior context is done, expose this as an int
|
||||
->Property("QueryType", [](const RayCastRequest& self) { return static_cast<int>(self.m_queryType); },
|
||||
[](RayCastRequest& self, int newQueryType) { self.m_queryType = SceneQuery::QueryType(newQueryType); })
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,21 +73,22 @@ namespace Physics
|
||||
{
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<Physics::CharacterRequestBus>("CharacterControllerRequestBus", "Character Controller")
|
||||
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::RuntimeOwn)
|
||||
behaviorContext->EBus<CharacterRequestBus>("CharacterControllerRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "physics")
|
||||
->Attribute(AZ::Edit::Attributes::Category, "PhysX")
|
||||
->Event("GetBasePosition", &Physics::CharacterRequests::GetBasePosition, "Get Base Position")
|
||||
->Event("SetBasePosition", &Physics::CharacterRequests::SetBasePosition, "Set Base Position")
|
||||
->Event("GetCenterPosition", &Physics::CharacterRequests::GetCenterPosition, "Get Center Position")
|
||||
->Event("GetStepHeight", &Physics::CharacterRequests::GetStepHeight, "Get Step Height")
|
||||
->Event("SetStepHeight", &Physics::CharacterRequests::SetStepHeight, "Set Step Height")
|
||||
->Event("GetUpDirection", &Physics::CharacterRequests::GetUpDirection, "Get Up Direction")
|
||||
->Event("GetSlopeLimitDegrees", &Physics::CharacterRequests::GetSlopeLimitDegrees, "Get Slope Limit (Degrees)")
|
||||
->Event("SetSlopeLimitDegrees", &Physics::CharacterRequests::SetSlopeLimitDegrees, "Set Slope Limit (Degrees)")
|
||||
->Event("GetMaximumSpeed", &Physics::CharacterRequests::GetMaximumSpeed, "Get Maximum Speed")
|
||||
->Event("SetMaximumSpeed", &Physics::CharacterRequests::SetMaximumSpeed, "Set Maximum Speed")
|
||||
->Event("GetVelocity", &Physics::CharacterRequests::GetVelocity, "Get Velocity")
|
||||
->Event("AddVelocity", &Physics::CharacterRequests::AddVelocity, "Add Velocity")
|
||||
->Event("GetBasePosition", &CharacterRequests::GetBasePosition, "Get Base Position")
|
||||
->Event("SetBasePosition", &CharacterRequests::SetBasePosition, "Set Base Position")
|
||||
->Event("GetCenterPosition", &CharacterRequests::GetCenterPosition, "Get Center Position")
|
||||
->Event("GetStepHeight", &CharacterRequests::GetStepHeight, "Get Step Height")
|
||||
->Event("SetStepHeight", &CharacterRequests::SetStepHeight, "Set Step Height")
|
||||
->Event("GetUpDirection", &CharacterRequests::GetUpDirection, "Get Up Direction")
|
||||
->Event("GetSlopeLimitDegrees", &CharacterRequests::GetSlopeLimitDegrees, "Get Slope Limit (Degrees)")
|
||||
->Event("SetSlopeLimitDegrees", &CharacterRequests::SetSlopeLimitDegrees, "Set Slope Limit (Degrees)")
|
||||
->Event("GetMaximumSpeed", &CharacterRequests::GetMaximumSpeed, "Get Maximum Speed")
|
||||
->Event("SetMaximumSpeed", &CharacterRequests::SetMaximumSpeed, "Set Maximum Speed")
|
||||
->Event("GetVelocity", &CharacterRequests::GetVelocity, "Get Velocity")
|
||||
->Event("AddVelocity", &CharacterRequests::AddVelocity, "Add Velocity")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user