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

Cursor::SetPos() がシーンサイズを考慮していない問題を修正 #1168

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Cursor::SetPos() がシーンサイズを考慮していない問題を修正
sashi0034 committed Dec 18, 2023
commit d4470070a86ccd65adfbd27ee4e1c4af8f79c826
Original file line number Diff line number Diff line change
@@ -198,8 +198,14 @@ namespace s3d

void CCursor::setPos(const Point pos)
{
const SizeF sceneSize = SIV3D_ENGINE(Renderer)->getSceneBufferSize();
const SizeF windowSize = SIV3D_ENGINE(Window)->getState().virtualSize;
const double sceneScale = (windowSize / sceneSize).minComponent();
const Vec2 sceneOffset = (windowSize - sceneSize * sceneScale) / 2;
const double scaling = SIV3D_ENGINE(Window)->getState().scaling;
POINT point{ static_cast<int32>(pos.x * scaling), static_cast<int32>(pos.y * scaling) };
const Vec2 actualPos = (pos * sceneScale + sceneOffset) * scaling;

POINT point{ static_cast<int32>(actualPos.x), static_cast<int32>(actualPos.y) };
::ClientToScreen(m_hWnd, &point);
::SetCursorPos(point.x, point.y);