-
Notifications
You must be signed in to change notification settings - Fork 12
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
TransformCtrl: Add new commands #254
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,9 @@ bool CameraComponent::onUpdate(Time) { | |
} | ||
|
||
bool CameraComponent::onRender(RenderBackendService *rbSrv) { | ||
osre_assert(nullptr != rbSrv); | ||
if (nullptr == rbSrv) { | ||
return false; | ||
} | ||
Comment on lines
+163
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the results from all our verification attempts, I can now generate the final response: Return value from CameraComponent::render() is not properly handled in callers The verification shows that callers of the render method do not properly handle the boolean return value:
The change to return false on null service should be accompanied by proper error handling in all calling code. 🔗 Analysis chainVerify error handling in callers. The change to return false on null service is good, but we should verify that callers handle this return value appropriately. Let me analyze the results and generate additional verification scripts to get more context about error handling. The first script will help us see the full context of camera rendering in World class. The second will show us the render method implementations to check error propagation. The third will give us more context around render calls in the App directory. Let me fix the ripgrep command and try again. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for calls to CameraComponent::render or onRender to verify error handling
ast-grep --pattern 'if ($component->render($service)) {
$$$
}'
# Also check for direct calls without error checking
rg -A 2 "\->render\(.*\)" --type cpp
Length of output: 2135 Script: #!/bin/bash
# Check the World class implementation for error handling of camera render
ast-grep --pattern 'mActiveCamera->render($service)'
# Check Entity class implementation for component render error handling
ast-grep --pattern 'render($service) {
$$$
}'
# Look for any error handling patterns around render calls
rg -B 2 -A 2 "->render\(" src/Engine/App/
Length of output: 553 Script: #!/bin/bash
# Check the World class implementation for error handling of camera render
rg -B 2 -A 2 "mActiveCamera\->render" src/Engine/App/
# Look for render method implementations
ast-grep --pattern 'bool render($service) {
$$$
}'
# Check for error handling patterns in caller code
rg -B 2 -A 2 "if.*->render" src/Engine/App/
Length of output: 363 |
||
|
||
rbSrv->setMatrix(MatrixType::View, mView); | ||
rbSrv->setMatrix(MatrixType::Projection, mProjection); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,16 +37,16 @@ namespace RenderBackend { | |
namespace App { | ||
|
||
/// @brief The class to manage the keyboard mappings for transform commands. | ||
struct KeyboardMap { | ||
struct InputMap { | ||
cppcore::TStaticArray<Animation::TransformCommandType, Platform::KEY_LAST> KeyArray; | ||
|
||
/// @brief The class constructor. | ||
KeyboardMap() { | ||
InputMap() { | ||
init(); | ||
} | ||
|
||
/// @brief The class destructor. | ||
~KeyboardMap() = default; | ||
~InputMap() = default; | ||
|
||
/// @brief Will initialize the array, no mapping is stored. | ||
void init() { | ||
|
@@ -57,20 +57,31 @@ struct KeyboardMap { | |
|
||
/// @brief Enables the default mapping. | ||
void setDefault() { | ||
KeyArray[Platform::KEY_A] = Animation::TransformCommandType::RotateXCommandPositive; | ||
KeyArray[Platform::KEY_a] = Animation::TransformCommandType::RotateXCommandPositive; | ||
KeyArray[Platform::KEY_D] = Animation::TransformCommandType::RotateXCommandNegative; | ||
KeyArray[Platform::KEY_d] = Animation::TransformCommandType::RotateXCommandNegative; | ||
KeyArray[Platform::KEY_W] = Animation::TransformCommandType::RotateYCommandPositive; | ||
KeyArray[Platform::KEY_w] = Animation::TransformCommandType::RotateYCommandPositive; | ||
KeyArray[Platform::KEY_S] = Animation::TransformCommandType::RotateYCommandNegative; | ||
KeyArray[Platform::KEY_s] = Animation::TransformCommandType::RotateYCommandNegative; | ||
KeyArray[Platform::KEY_Q] = Animation::TransformCommandType::RotateZCommandPositive; | ||
KeyArray[Platform::KEY_q] = Animation::TransformCommandType::RotateZCommandPositive; | ||
KeyArray[Platform::KEY_E] = Animation::TransformCommandType::RotateZCommandNegative; | ||
KeyArray[Platform::KEY_e] = Animation::TransformCommandType::RotateZCommandNegative; | ||
KeyArray[Platform::KEY_Q] = Animation::TransformCommandType::RotateXCommandPositive; | ||
KeyArray[Platform::KEY_q] = Animation::TransformCommandType::RotateXCommandPositive; | ||
KeyArray[Platform::KEY_E] = Animation::TransformCommandType::RotateXCommandNegative; | ||
KeyArray[Platform::KEY_e] = Animation::TransformCommandType::RotateXCommandNegative; | ||
KeyArray[Platform::KEY_y] = Animation::TransformCommandType::RotateYCommandPositive; | ||
KeyArray[Platform::KEY_Y] = Animation::TransformCommandType::RotateYCommandPositive; | ||
KeyArray[Platform::KEY_c] = Animation::TransformCommandType::RotateYCommandNegative; | ||
KeyArray[Platform::KEY_C] = Animation::TransformCommandType::RotateYCommandNegative; | ||
KeyArray[Platform::KEY_s] = Animation::TransformCommandType::RotateZCommandPositive; | ||
KeyArray[Platform::KEY_S] = Animation::TransformCommandType::RotateZCommandPositive; | ||
KeyArray[Platform::KEY_f] = Animation::TransformCommandType::RotateZCommandNegative; | ||
KeyArray[Platform::KEY_F] = Animation::TransformCommandType::RotateZCommandNegative; | ||
Comment on lines
+68
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve conflicting key mappings for The keys
This conflict will cause ambiguity in input handling, leading to unexpected behavior when the To fix this issue, assign different keys to one set of commands. For example, you could change the keys for the rotation commands: - KeyArray[Platform::KEY_s] = Animation::TransformCommandType::RotateZCommandPositive;
- KeyArray[Platform::KEY_S] = Animation::TransformCommandType::RotateZCommandPositive;
- KeyArray[Platform::KEY_f] = Animation::TransformCommandType::RotateZCommandNegative;
- KeyArray[Platform::KEY_F] = Animation::TransformCommandType::RotateZCommandNegative;
+ KeyArray[Platform::KEY_z] = Animation::TransformCommandType::RotateZCommandPositive;
+ KeyArray[Platform::KEY_Z] = Animation::TransformCommandType::RotateZCommandPositive;
+ KeyArray[Platform::KEY_x] = Animation::TransformCommandType::RotateZCommandNegative;
+ KeyArray[Platform::KEY_X] = Animation::TransformCommandType::RotateZCommandNegative; Alternatively, adjust the keys for the translation commands to resolve the conflict. Also applies to: 77-78 |
||
KeyArray[Platform::KEY_PLUS] = Animation::TransformCommandType::ScaleInCommand; | ||
KeyArray[Platform::KEY_MINUS] = Animation::TransformCommandType::ScaleOutCommand; | ||
|
||
KeyArray[Platform::KEY_w] = Animation::TransformCommandType::TransformCommandXPositive; | ||
KeyArray[Platform::KEY_W] = Animation::TransformCommandType::TransformCommandXPositive; | ||
KeyArray[Platform::KEY_s] = Animation::TransformCommandType::TransformCommandXNegative; | ||
KeyArray[Platform::KEY_S] = Animation::TransformCommandType::TransformCommandXNegative; | ||
|
||
KeyArray[Platform::KEY_a] = Animation::TransformCommandType::TransformCommandYNegative; | ||
KeyArray[Platform::KEY_A] = Animation::TransformCommandType::TransformCommandYNegative; | ||
|
||
KeyArray[Platform::KEY_d] = Animation::TransformCommandType::TransformCommandYPositive; | ||
KeyArray[Platform::KEY_D] = Animation::TransformCommandType::TransformCommandYPositive; | ||
} | ||
|
||
/// @brief Set a new mapping. | ||
|
@@ -122,7 +133,14 @@ class OSRE_EXPORT TransformController : public Animation::AnimationControllerBas | |
void update(Animation::TransformCommandType cmdType) override; | ||
|
||
private: | ||
KeyboardMap mKeyboardMap; | ||
struct TransformConfig { | ||
f32 mScaleFactorPlus = 1.01f; | ||
f32 mScaleFactorMinus = 0.99f; | ||
f32 mRotateFactor = 0.01f; | ||
f32 mTranslateFactor = 0.15f; | ||
}; | ||
TransformConfig mTransformConfig; | ||
InputMap mInputMap; | ||
RenderBackend::TransformMatrixBlock &mTransform; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Z-axis transform commands are missing in the implementation
The switch statement in
TransformController::update
is missing cases forTransformCommandZPositive
andTransformCommandZNegative
, although these commands are defined in the enum. The implementation needs to be updated to handle Z-axis translations similar to X and Y axes.Missing implementations:
case TransformCommandType::TransformCommandZPositive
case TransformCommandType::TransformCommandZNegative
🔗 Analysis chain
Verify implementation of new transform commands.
The new transform commands will need proper handling in all derived classes of
AnimationControllerBase
. Please ensure:TransformCommandType
are updatedgetKeyBinding
implementations map appropriate keys to new commandsupdate
implementations handle the new transform casesLet me try a different search strategy to find the implementations.
Let me search for the implementation files and the specific handling of transform commands.
Let me check for the Z-axis transform commands which seem to be missing in the switch statement.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 393
Script:
Length of output: 1389
Script:
Length of output: 10552
Script:
Length of output: 800