mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-04 20:57:49 +00:00
fahhh
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
/*
|
||||
// End user tools
|
||||
|
||||
GameTool (select top parts for dragging, close to character)
|
||||
-> PartDragTool (called for dragging)
|
||||
|
||||
GrabTool (drag parts and models in game)
|
||||
-> DragTool (called for dragging)
|
||||
|
||||
ArrowTool (i.e. - powerpoint - select, box select, shift select, drag)
|
||||
-> DragTool (called for dragging)
|
||||
|
||||
// Auxillary (private)
|
||||
PartDragTool (drag a single part)
|
||||
|
||||
GroupDragTool (drag a group of parts, or a model, or a selection of parts/models)
|
||||
|
||||
DragTool
|
||||
-> PartDragTool (part dragging)
|
||||
-> GroupDragTool (>1 part, or model dragging)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace RBX {
|
||||
|
||||
// TEMP COMMENT: verify merging...
|
||||
class Workspace;
|
||||
class PartInstance;
|
||||
class PVInstance;
|
||||
|
||||
class AdvDragTool
|
||||
{
|
||||
public:
|
||||
static shared_ptr<MouseCommand> onMouseDown(PartInstance* hitPart,
|
||||
const Vector3& hitWorld,
|
||||
const std::vector<Instance*>& dragInstances,
|
||||
const shared_ptr<InputObject>& inputObject,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag);
|
||||
// TEMP COMMENT: Verifying merge...
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,51 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/ToolsArrow.h"
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
#include "Tool/AdvLuaDragger.h"
|
||||
#include "Util/Math.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class PartInstance;
|
||||
|
||||
extern const char* const sAdvLuaDragTool;
|
||||
|
||||
class AdvLuaDragTool : public Named<AdvArrowToolBase, sAdvLuaDragTool>
|
||||
{
|
||||
private:
|
||||
typedef Named<AdvArrowToolBase, sAdvLuaDragTool> Super;
|
||||
boost::shared_ptr<AdvLuaDragger> advLuaDragger;
|
||||
boost::weak_ptr<Instance> selectIfNoDrag;
|
||||
std::string cursor;
|
||||
bool dragging;
|
||||
G3D::Vector2 downPoint2d;
|
||||
|
||||
bool canDrag(const shared_ptr<InputObject>& inputObject) const;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const { return cursor; }
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void setCursor(std::string newCursor) { cursor = newCursor; }
|
||||
|
||||
public:
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
AdvLuaDragTool( PartInstance* mousePart,
|
||||
const Vector3& hitPointWorld,
|
||||
const std::vector<weak_ptr<PartInstance> >& partArray,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag);
|
||||
|
||||
~AdvLuaDragTool();
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8Tree/Instance.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class Joint;
|
||||
class PartInstance;
|
||||
class ContactManager;
|
||||
class AdvRunDragger;
|
||||
|
||||
extern const char* const sAdvLuaDragger;
|
||||
|
||||
class AdvLuaDragger
|
||||
: public DescribedCreatable<AdvLuaDragger, Instance, sAdvLuaDragger>
|
||||
{
|
||||
private:
|
||||
typedef enum {NO_PARTS, MOUSE_DOWN, DRAGGING, MOUSE_UP_DRAGGED, MOUSE_UP_NO_DRAG} DragPhase;
|
||||
DragPhase dragPhase;
|
||||
|
||||
std::vector<shared_ptr<Joint> > jointsIMade;
|
||||
weak_ptr<PartInstance> rootPart;
|
||||
std::auto_ptr<AdvRunDragger> advRunDragger; // only if we have one part
|
||||
|
||||
float hitPointHeight;
|
||||
|
||||
typedef std::vector<weak_ptr<PartInstance> > WeakParts;
|
||||
WeakParts dragParts;
|
||||
weak_ptr<PartInstance> mousePart;
|
||||
Vector3 pointOnMousePart;
|
||||
Vector3 hitPointOffset; //at the start of the drag process this the vector from
|
||||
//the hitPoint on the background to hit point on the mouse part
|
||||
|
||||
std::vector<CoordinateFrame> m_originalPositions;
|
||||
|
||||
void tryStartDragging(const RBX::RbxRay& unitMouseRay);
|
||||
void startDragging();
|
||||
void doDrag(const RBX::RbxRay& unitMouseRay);
|
||||
bool getSnapHitPoint(PartInstance* part, const RBX::RbxRay& unitMouseRay, Vector3& hitPoint);
|
||||
ContactManager& getContactManager(PartInstance* partInstance);
|
||||
|
||||
const float breakFreeDistance(); // distance in studs at the mouse down point before movement
|
||||
|
||||
void addPart(shared_ptr<const Instance> part);
|
||||
/*override*/ bool askSetParent(const Instance* instance) const { return false; }
|
||||
|
||||
public:
|
||||
AdvLuaDragger();
|
||||
~AdvLuaDragger();
|
||||
|
||||
void mouseDownPublic(shared_ptr<Instance> _mousePart,
|
||||
Vector3 _pointOnMousePart,
|
||||
shared_ptr<const Instances> _dragParts);
|
||||
|
||||
void mouseDown( shared_ptr<PartInstance> _mousePart,
|
||||
const Vector3& _pointOnMousePart,
|
||||
const std::vector<weak_ptr<PartInstance> > _dragParts);
|
||||
|
||||
void mouseMove(RBX::RbxRay mouseRay); // inefficient, but easier to have just one version
|
||||
|
||||
void mouseUp();
|
||||
|
||||
const WeakParts& getParts() {return dragParts;}
|
||||
|
||||
void rotateOnSnapFace(Vector3::Axis, const Matrix3& rotMatrix);
|
||||
|
||||
void axisRotate(Vector3::Axis axis);
|
||||
|
||||
bool isDragging() const {return dragPhase == DRAGGING;}
|
||||
|
||||
bool didDrag() const {return dragPhase == MOUSE_UP_DRAGGED;}
|
||||
|
||||
void toggleRunDraggerRotateMode( void );
|
||||
void toggleRunDraggerJointCreateMode( void );
|
||||
void alignPartToGrid( void );
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,109 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/ToolsArrow.h"
|
||||
#include "Tool/MegaDragger.h"
|
||||
#include "AppDraw/HandleType.h"
|
||||
#include "Util/NormalId.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class MegaDragger;
|
||||
class Extents;
|
||||
|
||||
class AdvMoveToolBase : public AdvArrowToolBase
|
||||
{
|
||||
protected:
|
||||
bool dragging;
|
||||
Ray dragRay;
|
||||
int dragAxis;
|
||||
int dragAxisDirection;
|
||||
NormalId dragNormalId;
|
||||
std::string cursor;
|
||||
|
||||
//TODO: Have a single variable in Move and Rotate tool
|
||||
mutable NormalId overHandleNormalId;
|
||||
|
||||
private:
|
||||
typedef AdvArrowToolBase Super;
|
||||
std::auto_ptr<MegaDragger> megaDragger;
|
||||
Vector2int16 downPoint2d;
|
||||
|
||||
// dynamic - last point on the Ray we dragged to
|
||||
// only works with one-stud grid...
|
||||
Vector3 lastPoint3d;
|
||||
|
||||
typedef std::map<boost::weak_ptr<RBX::PartInstance>, float> PartsTransparencyCollection;
|
||||
PartsTransparencyCollection origPartsTransparency;
|
||||
|
||||
mutable Matrix3 mMultiRotation;
|
||||
mutable Extents mExtents;
|
||||
mutable bool mInitializedExtents;
|
||||
|
||||
float snapRotationAngle(float Angle) const;
|
||||
void saveAndModifyPartsTransparency();
|
||||
void restoreSavedPartsTransparency();
|
||||
|
||||
rbx::signals::scoped_connection selectionChangedConnection;
|
||||
void setToSelection();
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool getLocalSpaceMode() const;
|
||||
virtual bool getOverHandle(const shared_ptr<InputObject>& inputObject, Vector3& hitPointWorld, NormalId& normalId) const;
|
||||
|
||||
bool getExtents(Extents& extents) const;
|
||||
bool getExtentsAndLocation(
|
||||
Extents& extents,
|
||||
CoordinateFrame& location,
|
||||
bool& isLocal ) const;
|
||||
bool getOverHandle(const shared_ptr<InputObject>& inputObject) const;
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
/*override*/ const std::string getCursorName() const {return cursor;}
|
||||
/*override*/ void setCursor(std::string newCursor) {cursor = newCursor;}
|
||||
|
||||
|
||||
/*implement*/ virtual Color3 getHandleColor() const = 0;
|
||||
/*implement*/ virtual HandleType getDragType() const = 0;
|
||||
|
||||
public:
|
||||
AdvMoveToolBase(Workspace* workspace);
|
||||
virtual ~AdvMoveToolBase()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
extern const char* const sAdvMoveTool;
|
||||
class AdvMoveTool : public Named<AdvMoveToolBase, sAdvMoveTool>
|
||||
{
|
||||
private:
|
||||
/*override*/ Color3 getHandleColor() const {return Color3::orange();}
|
||||
/*override*/ HandleType getDragType() const {return HANDLE_MOVE;}
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
void getGridXYUsingCamera(RBX::PartInstance *part, G3D::Vector3 &gridXDir, G3D::Vector3 &gridYDir);
|
||||
|
||||
G3D::Vector3 originalLocation;
|
||||
|
||||
public:
|
||||
AdvMoveTool(Workspace* workspace) : Named<AdvMoveToolBase, sAdvMoveTool>(workspace)
|
||||
{}
|
||||
~AdvMoveTool() {}
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<AdvMoveTool>(workspace);}
|
||||
};
|
||||
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/AdvMoveTool.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sAdvRotateTool;
|
||||
class AdvRotateTool : public Named<AdvMoveToolBase, sAdvRotateTool>
|
||||
{
|
||||
private:
|
||||
typedef Named<AdvMoveToolBase, sAdvRotateTool> Super;
|
||||
|
||||
int getNormalMask() const;
|
||||
|
||||
mutable NormalId mOverHandleNormalId;
|
||||
|
||||
protected:
|
||||
|
||||
virtual Color3 getHandleColor() const {return Color3::green();}
|
||||
virtual HandleType getDragType() const {return HANDLE_ROTATE;}
|
||||
virtual bool getLocalSpaceMode() const;
|
||||
virtual bool getOverHandle(const shared_ptr<InputObject>& inputObject, Vector3& hitPointWorld, NormalId& normalId) const;
|
||||
|
||||
public:
|
||||
AdvRotateTool(Workspace* workspace) :
|
||||
Named<AdvMoveToolBase, sAdvRotateTool>(workspace),
|
||||
mOverHandleNormalId(NORM_UNDEFINED)
|
||||
{}
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<AdvRotateTool>(workspace);}
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,155 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8World/Contact.h"
|
||||
#include "Util/Object.h"
|
||||
#include "Util/G3DCore.h"
|
||||
#include "Util/NormalId.h"
|
||||
#include <vector>
|
||||
#include "Tool/DragTypes.h"
|
||||
#include "AppDraw/DrawAdorn.h"
|
||||
#include "GfxBase/Adorn.h"
|
||||
#include "GfxBase/IAdornable.h"
|
||||
|
||||
//#define DEBUG_MULTIPLE_PARTS_DRAG
|
||||
|
||||
namespace RBX {
|
||||
class Primitive;
|
||||
class PartInstance;
|
||||
class Workspace;
|
||||
typedef std::vector<weak_ptr<PartInstance> > WeakParts;
|
||||
typedef std::vector<CoordinateFrame> Locations;
|
||||
|
||||
class AdvRunDragger : public IAdornable
|
||||
{
|
||||
private:
|
||||
class SnapInfo {
|
||||
public:
|
||||
Primitive* snap;
|
||||
NormalId surface;
|
||||
size_t mySurfaceId;
|
||||
Vector3 hitWorld;
|
||||
Vector3 lastDragSnap;
|
||||
SnapInfo()
|
||||
: snap(NULL)
|
||||
, surface(NORM_UNDEFINED)
|
||||
, mySurfaceId((size_t)-1)
|
||||
, hitWorld(Vector3::inf())
|
||||
, lastDragSnap(Vector3::inf())
|
||||
{}
|
||||
void updateHitFromSurface(const RbxRay& mouseRay);
|
||||
void updateSurfaceFromHit();
|
||||
float hitOutsideExtents();
|
||||
};
|
||||
|
||||
// Initialized
|
||||
// Poor man's version - ultimately, change all internally to shared_ptr's
|
||||
weak_ptr<PartInstance> dragPart;
|
||||
std::vector<Primitive*> dragParts;
|
||||
WeakParts weakDragParts;
|
||||
weak_ptr<PartInstance> snapPart;
|
||||
|
||||
bool isAdornable;
|
||||
Workspace* workspace;
|
||||
Primitive* drag;
|
||||
Vector3 dragPointLocal;
|
||||
Matrix3 dragOriginalRotation;
|
||||
|
||||
// Carry forward data
|
||||
SnapInfo snapInfo;
|
||||
|
||||
// Set on every snap() call
|
||||
RbxRay mouseRay;
|
||||
|
||||
// Computed every snap() call
|
||||
NormalId dragSurface; // computed
|
||||
// Angled surface testing...
|
||||
size_t myDragSurfaceId; // computed
|
||||
Vector3 dragHitLocal; // computed
|
||||
|
||||
Vector3 snapGridOrigin;
|
||||
bool snapGridOriginNeedsUpdating;
|
||||
|
||||
// modes
|
||||
DRAG::DraggerGridMode gridMode;
|
||||
bool jointCreateMode;
|
||||
|
||||
// new multiple drag
|
||||
boost::shared_ptr<RBX::PartInstance> tempPart;
|
||||
Locations originalLocations;
|
||||
G3D::Array<Primitive*> savedPrimsForMultiDrag;
|
||||
PartInstance* primaryPart;
|
||||
bool handleMultipleParts;
|
||||
CoordinateFrame tempOriginalCF;
|
||||
|
||||
SnapInfo createSnapSurface(Primitive* snap, G3D::Array<size_t>* ignore = NULL);
|
||||
bool moveDragPart();
|
||||
bool snapDragPart(bool supressGridSettings = false);
|
||||
bool pushDragPart(const Vector3& snapNormal);
|
||||
|
||||
void findSafeY();
|
||||
bool notTried(Primitive* check, const G3D::Array<Primitive*>& tried);
|
||||
bool adjacent(Primitive* p0, Primitive* p1);
|
||||
SnapInfo rayHitsPart(const G3D::Array<Primitive*>& triedSnap, bool forceAdjacent);
|
||||
SnapInfo bestProximatePart(const G3D::Array<Primitive*>& triedSnap,
|
||||
Contact::ProximityTest proximityTest);
|
||||
bool fallOffEdge();
|
||||
|
||||
bool fallOffPart(bool& snapped);
|
||||
bool colliding();
|
||||
bool rayHitsCloserPart();
|
||||
bool tooCloseToCamera();
|
||||
|
||||
SnapInfo findSnap(const G3D::Array<Primitive*>& triedSnap);
|
||||
void findNoSnapPosition(const CoordinateFrame& original);
|
||||
|
||||
void snapInfoFromSnapPart();
|
||||
void snapPartFromSnapInfo();
|
||||
|
||||
void savePrimsForMultiDrag();
|
||||
Contact* getFirstContact(Primitive*& prim);
|
||||
Contact* getNextContact(Primitive*& prim, Contact* c);
|
||||
|
||||
public:
|
||||
AdvRunDragger();
|
||||
~AdvRunDragger();
|
||||
void init( Workspace* _workspace,
|
||||
weak_ptr<PartInstance> _dragPart,
|
||||
const Vector3& _dragPointWorld);
|
||||
void initLocal( Workspace* _workspace,
|
||||
weak_ptr<PartInstance> _dragPart,
|
||||
const Vector3& _dragPointLocal,
|
||||
WeakParts _dragParts);
|
||||
|
||||
bool snap(const RbxRay& mouseRay);
|
||||
bool snapGroup(const RbxRay& _mouseRay);
|
||||
bool getSnapHitPoint(PartInstance* part, const RbxRay& unitMouseRay, Vector3& hitPoint);
|
||||
|
||||
void rotatePartAboutSnapFaceAxis( Vector3::Axis axis, const float& angleInRads );
|
||||
void rotatePart90DegAboutSnapFaceAxis( Vector3::Axis axis );
|
||||
|
||||
// Note: these will NOT update dragOriginalRotation
|
||||
static void turnUpright(PartInstance* part);
|
||||
static void rotatePart(PartInstance* part);
|
||||
static void tiltPart(PartInstance* part, const CoordinateFrame& camera);
|
||||
|
||||
void setGridMode( DRAG::DraggerGridMode mode ) { gridMode = mode; }
|
||||
DRAG::DraggerGridMode getGridMode( void ) { return gridMode; }
|
||||
void setJointCreateMode( bool mode ) { jointCreateMode = mode; }
|
||||
bool getJointCreateMode( void ) { return jointCreateMode; }
|
||||
CoordinateFrame getSnapSurfaceCoord( void );
|
||||
|
||||
#ifdef DEBUG_MULTIPLE_PARTS_DRAG
|
||||
// IAdornable
|
||||
bool shouldRender3dAdorn() const { return true; }
|
||||
void render3dAdorn(Adorn* adorn);
|
||||
#else
|
||||
// IAdornable
|
||||
bool shouldRender3dAdorn() const { return false; }
|
||||
#endif
|
||||
|
||||
static bool dragMultiPartsAsSinglePart;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/ToolsArrow.h"
|
||||
#include "Tool/MegaDragger.h"
|
||||
#include "AppDraw/HandleType.h"
|
||||
#include "Util/NormalId.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class MegaDragger;
|
||||
class Extents;
|
||||
|
||||
class AxisToolBase : public ArrowToolBase
|
||||
{
|
||||
private:
|
||||
typedef ArrowToolBase Super;
|
||||
std::auto_ptr<MegaDragger> megaDragger;
|
||||
std::string cursor;
|
||||
bool dragging;
|
||||
Vector2int16 downPoint2d;
|
||||
RbxRay dragRay;
|
||||
int dragAxis;
|
||||
|
||||
// dynamic - last point on the Ray we dragged to
|
||||
Vector3 lastPoint3d;
|
||||
|
||||
bool getExtents(Extents& extents) const;
|
||||
bool getOverHandle(const shared_ptr<InputObject>& inputObject) const;
|
||||
bool getOverHandle(const shared_ptr<InputObject>& inputObject, Vector3& hitPointWorld, NormalId& normalId) const;
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
protected:
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
/*override*/ const std::string getCursorName() const {return cursor;}
|
||||
|
||||
/*implement*/ virtual Color3 getHandleColor() const = 0;
|
||||
/*implement*/ virtual HandleType getDragType() const = 0;
|
||||
|
||||
public:
|
||||
AxisToolBase(Workspace* workspace);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,25 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/AxisMoveTool.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sAxisRotateTool;
|
||||
class AxisRotateTool : public Named<AxisToolBase, sAxisRotateTool>
|
||||
{
|
||||
private:
|
||||
/*override*/ Color3 getHandleColor() const {return Color3::green();}
|
||||
/*override*/ HandleType getDragType() const {return HANDLE_ROTATE;}
|
||||
|
||||
public:
|
||||
AxisRotateTool(Workspace* workspace) : Named<AxisToolBase, sAxisRotateTool>(workspace)
|
||||
{}
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<AxisRotateTool>(workspace);}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class PartInstance;
|
||||
|
||||
extern const char* const sCloneTool;
|
||||
class CloneTool : public Named<MouseCommand, sCloneTool>
|
||||
{
|
||||
private:
|
||||
shared_ptr<PartInstance> clonePart;
|
||||
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const;
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
public:
|
||||
CloneTool(Workspace* workspace);
|
||||
~CloneTool();
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<CloneTool>(workspace);}
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
/*
|
||||
// End user tools
|
||||
|
||||
GameTool (select top parts for dragging, close to character)
|
||||
-> PartDragTool (called for dragging)
|
||||
|
||||
GrabTool (drag parts and models in game)
|
||||
-> DragTool (called for dragging)
|
||||
|
||||
ArrowTool (i.e. - powerpoint - select, box select, shift select, drag)
|
||||
-> DragTool (called for dragging)
|
||||
|
||||
// Auxillary (private)
|
||||
PartDragTool (drag a single part)
|
||||
|
||||
GroupDragTool (drag a group of parts, or a model, or a selection of parts/models)
|
||||
|
||||
DragTool
|
||||
-> PartDragTool (part dragging)
|
||||
-> GroupDragTool (>1 part, or model dragging)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class Workspace;
|
||||
class PartInstance;
|
||||
class PVInstance;
|
||||
|
||||
class DragTool
|
||||
{
|
||||
public:
|
||||
static shared_ptr<MouseCommand> onMouseDown( PartInstance* hitPart,
|
||||
const Vector3& hitWorld,
|
||||
const std::vector<Instance*>& dragInstances,
|
||||
const shared_ptr<InputObject>& inputObject,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag);
|
||||
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace RBX {
|
||||
namespace DRAG {
|
||||
|
||||
typedef enum {NO_UNJOIN_NO_JOIN, UNJOIN_JOIN, UNJOIN_NO_JOIN} JoinType;
|
||||
|
||||
typedef enum {MOVE_DROP, MOVE_NO_DROP} MoveType;
|
||||
|
||||
typedef enum {WEAK_MANUAL_JOINT, STRONG_MANUAL_JOINT, INFINITE_MANUAL_JOINT} ManualJointType;
|
||||
|
||||
typedef enum {ONE_STUD, QUARTER_STUD, OFF} DraggerGridMode;
|
||||
|
||||
}
|
||||
} // namespace
|
||||
@@ -0,0 +1,100 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Util/Object.h"
|
||||
#include "Util/G3DCore.h"
|
||||
#include "Util/Extents.h"
|
||||
#include "Tool/Dragger.h"
|
||||
|
||||
namespace RBX {
|
||||
class Instance;
|
||||
class PartInstance;
|
||||
class Primitive;
|
||||
class PVInstance;
|
||||
class ContactManager;
|
||||
class World;
|
||||
|
||||
typedef std::vector<weak_ptr<PartInstance> > PartArray;
|
||||
|
||||
class DragUtilities
|
||||
{
|
||||
private:
|
||||
static bool hitObjectOrPlane(const ContactManager& contactManager,
|
||||
const RbxRay& unitSearchRay,
|
||||
const std::vector<const Primitive*>& ignorePrims,
|
||||
Vector3& hit,
|
||||
bool snapToGrid = true);
|
||||
static bool hitObject( const ContactManager& contactManager,
|
||||
const RbxRay& unitSearchRay,
|
||||
const std::vector<const Primitive*>& ignorePrims,
|
||||
Vector3& hit,
|
||||
bool snapToGrid = true);
|
||||
|
||||
public:
|
||||
static bool notJoined(const PartArray& parts);
|
||||
static bool notJoinedToOutsiders(const PartArray& parts);
|
||||
|
||||
static void unJoinFromOutsiders(const PartArray& parts);
|
||||
static void joinToOutsiders(const PartArray& parts);
|
||||
|
||||
static void unJoin(const PartArray& parts);
|
||||
static void join(const PartArray& parts);
|
||||
static void joinWithInPartsOnly(const PartArray& parts);
|
||||
|
||||
static void setDragging(const PartArray& parts);
|
||||
static void stopDragging(const PartArray& parts);
|
||||
|
||||
static void clean(const PartArray& parts);
|
||||
static void move(const PartArray& parts,
|
||||
CoordinateFrame from,
|
||||
CoordinateFrame to);
|
||||
static void move2(const PartArray& parts,
|
||||
CoordinateFrame from,
|
||||
CoordinateFrame to);
|
||||
|
||||
static void alignToGrid(PartInstance* part); // force alignement to grid
|
||||
static void clean(PartInstance* part); // clean up alignment if already aligned
|
||||
static void moveByDelta(PartInstance* part, const Vector3& delta, bool snapToWorld);
|
||||
|
||||
static void pvsToParts(const std::vector<PVInstance*>& pvInstances, PartArray& parts);
|
||||
static void instancesToParts(const std::vector<Instance*>& instances, PartArray& parts);
|
||||
static void instancesToParts(const Instances& instances, PartArray& parts);
|
||||
static void removeDuplicateParts(PartArray& parts);
|
||||
|
||||
static World* partsToPrimitives(const PartArray& parts, G3D::Array<Primitive*>& primitives);
|
||||
static void partsToPrimitives(const PartArray& parts, std::vector<const Primitive*>& primitives);
|
||||
static void partsToPrimitives(const PartArray& parts, std::vector<Primitive*>& primitives);
|
||||
|
||||
static Extents computeExtents(const PartArray& parts);
|
||||
|
||||
static Vector3 hitObjectOrPlane(const PartArray& parts,
|
||||
const RbxRay& unitMouseRay,
|
||||
const ContactManager& contactManager,
|
||||
bool snapToGrid = true);
|
||||
|
||||
static bool hitObject(const PartArray& parts,
|
||||
const RbxRay& unitMouseRay,
|
||||
const ContactManager& contactManager,
|
||||
Vector3& hit,
|
||||
bool snapToGrid = true);
|
||||
|
||||
static bool anyPartAlive(const PartArray& parts);
|
||||
|
||||
// replacement for PVInstance::getPrimitives();
|
||||
|
||||
static void getPrimitives2(shared_ptr<Instance> instance, std::vector<Primitive*>& primitives) {
|
||||
getPrimitives(instance.get(), primitives);
|
||||
}
|
||||
|
||||
static void getPrimitives(const Instance* instance, std::vector<Primitive*>& primitives);
|
||||
|
||||
static void getPrimitivesConst(const Instance* instance, std::vector<const Primitive*>& primitives);
|
||||
|
||||
static Vector3 safeMoveYDrop(const PartArray& parts, const Vector3& tryDrag, ContactManager& contactManager, const float customPlaneHeight = Dragger::groundPlaneDepth() );
|
||||
static Vector3 toGrid(const Vector3 &point, const Vector3& grid = Vector3::zero());
|
||||
static Vector3 toLocalGrid(const Vector3& deltaIn);
|
||||
static Vector3 getGrid();
|
||||
|
||||
};
|
||||
} // namespace
|
||||
@@ -0,0 +1,190 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
#include "Util/G3DCore.h"
|
||||
#include "Util/Extents.h"
|
||||
#include <vector>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class PVInstance;
|
||||
class Primitive;
|
||||
class ContactManager;
|
||||
class PartInstance;
|
||||
|
||||
class Dragger {
|
||||
private:
|
||||
static void primitivesFromInstances(const std::vector<PVInstance*>& pvInstances,
|
||||
G3D::Array<Primitive*>& primitives);
|
||||
|
||||
// Intersection tests
|
||||
static bool intersectingWorldOrOthers( const G3D::Array<Primitive*>& primitives,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight);
|
||||
|
||||
static void movePrimitives( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& delta,
|
||||
bool snapToWorld = true);
|
||||
|
||||
static void movePrimitivesDelta(const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& delta,
|
||||
Vector3& movedSoFar);
|
||||
|
||||
static bool movePrimitivesGoal( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& goal,
|
||||
Vector3& movedSoFar,
|
||||
bool snapToWorld = true);
|
||||
|
||||
static void safePlaceAlongLine( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& startMove,
|
||||
const Vector3& endMove,
|
||||
Vector3& movedSoFar,
|
||||
ContactManager& contactManager,
|
||||
bool snapToWorld = true);
|
||||
|
||||
static void searchFine( const G3D::Array<Primitive*> primitives,
|
||||
Vector3& movedSoFar,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight,
|
||||
Vector3 insidePosition,
|
||||
Vector3 outsidePosition);
|
||||
|
||||
static void searchUpGross( const G3D::Array<Primitive*>& primitives,
|
||||
Vector3& movedSoFar,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight);
|
||||
|
||||
static void searchDownGross( const G3D::Array<Primitive*>& primitives,
|
||||
Vector3& movedSoFar,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight);
|
||||
|
||||
static bool intersectingGroundPlane(const G3D::Array<Primitive*>& primitives, float yHeight);
|
||||
|
||||
static Vector3 safeMoveYDrop_EXT( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& tryMove,
|
||||
ContactManager& contactManager,
|
||||
const float customPlaneHeight = groundPlaneDepth());
|
||||
|
||||
static void searchUpGross_EXT( std::vector<RBX::Extents> &primExtents,
|
||||
const G3D::Array<Primitive*>& primitives,
|
||||
const boost::unordered_set<const Primitive*> &ignorePrimitives,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight,
|
||||
Vector3& movedSoFar);
|
||||
|
||||
static void searchDownGross_EXT( std::vector<RBX::Extents> &primExtents,
|
||||
const G3D::Array<Primitive*>& primitives,
|
||||
const boost::unordered_set<const Primitive*> &ignorePrimitives,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight,
|
||||
Vector3& movedSoFar);
|
||||
|
||||
static void searchUpFine_EXT( std::vector<RBX::Extents> &primExtents,
|
||||
const G3D::Array<Primitive*>& primitives,
|
||||
const boost::unordered_set<const Primitive*> &ignorePrimitives,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight,
|
||||
Vector3& movedSoFar);
|
||||
|
||||
static void searchDownFine_EXT( std::vector<RBX::Extents> &primExtents,
|
||||
const G3D::Array<Primitive*>& primitives,
|
||||
const boost::unordered_set<const Primitive*> &ignorePrimitives,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight,
|
||||
Vector3& movedSoFar);
|
||||
|
||||
static bool intersectingWorldOrOthers_EXT( std::vector<RBX::Extents> &primExtents,
|
||||
const G3D::Array<Primitive*>& primitives,
|
||||
const boost::unordered_set<const Primitive*> &ignorePrimitives,
|
||||
ContactManager& contactManager,
|
||||
const float bottomPlaneHeight,
|
||||
const Vector3& movedSoFar);
|
||||
|
||||
static bool intersectingGroundPlane_EXT( const std::vector<RBX::Extents>& primExtents,
|
||||
const G3D::Array<Primitive*>& primitives,
|
||||
const float yHeight,
|
||||
const Vector3& movedSoFar);
|
||||
|
||||
static bool isIntersecting(const Primitive* prim1, const CoordinateFrame &cFrame1, const Primitive* prim2, const CoordinateFrame &cFrame2);
|
||||
|
||||
static bool checkBallPolyIntersection(const Primitive* ballPrim, const CoordinateFrame &ballCFrame, const Primitive* polyPrim, const CoordinateFrame &polyCFrame);
|
||||
static bool checkBallBallIntersection(const Primitive* ballPrim1, const CoordinateFrame &ballCFrame1, const Primitive* ballPrim2, const CoordinateFrame &ballCFrame2);
|
||||
static bool checkPolyPolyIntersection(const Primitive* polyPrim1, const CoordinateFrame &polyCFrame1, const Primitive* polyPrim2, const CoordinateFrame &polyCFrame2);
|
||||
|
||||
static void moveExtents(std::vector<RBX::Extents> &primExtents, const Vector3& delta);
|
||||
static void moveExtentsDelta(std::vector<RBX::Extents> &primExtents, const Vector3& delta, Vector3& movedSoFar);
|
||||
|
||||
public:
|
||||
static const Vector3& dragSnap() {
|
||||
static Vector3 v(1.0f, 0.1f, 1.0f);
|
||||
return v;
|
||||
}
|
||||
// Physics automatically removes parts that fall lower than -500.
|
||||
// We'll allow dragging, moving, resizing down to -400.
|
||||
static float maxDragDepth() { return -400.0f; }
|
||||
static float groundPlaneDepth() { return 0.0f; }
|
||||
|
||||
// Moves up as necessary for no overlap
|
||||
static Vector3 safeMoveNoDrop( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& tryMove,
|
||||
ContactManager& contactManager);
|
||||
|
||||
// Floating - move down; Intersecting - move up
|
||||
static Vector3 safeMoveYDrop( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& tryMove,
|
||||
ContactManager& contactManager,
|
||||
const float customPlaneHeight = groundPlaneDepth() );
|
||||
|
||||
// Move along line - quickly find farthest safe move
|
||||
static Vector3 safeMoveAlongLine( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& tryMove,
|
||||
ContactManager& contactManager,
|
||||
const float customPlaneHeight = groundPlaneDepth(),
|
||||
bool snapToWorld = true );
|
||||
|
||||
static Vector3 safeRotateAlongLine( const G3D::Array<Primitive*>& primitives,
|
||||
const Vector3& tryMove,
|
||||
ContactManager& contactManager);
|
||||
|
||||
// Rotate around a grid point, then find a safe place
|
||||
static void safeRotate( const G3D::Array<Primitive*>& primitives,
|
||||
const Matrix3& rotate,
|
||||
ContactManager& contactManager);
|
||||
|
||||
static void safeRotate2( const G3D::Array<Primitive*>& primitives,
|
||||
const Matrix3& rotate,
|
||||
ContactManager& contactManager);
|
||||
|
||||
static Extents computeExtents(const std::vector<Primitive*>& primitives);
|
||||
|
||||
static Extents computeExtentsRelative(const std::vector<Primitive*>& primitives, CoordinateFrame& relativeFrame);
|
||||
|
||||
static Extents computeExtentsRelative(const G3D::Array<Primitive*>& primitives, CoordinateFrame& relativeFrame);
|
||||
|
||||
static PartInstance* computePrimaryPart(const std::vector<Primitive*>& primitives);
|
||||
|
||||
static PartInstance* computePrimaryPart(const G3D::Array<Primitive*>& primitives);
|
||||
|
||||
// Intersection tests
|
||||
static bool intersectingWorldOrOthers( PartInstance& partInstance,
|
||||
ContactManager& contactManager,
|
||||
const float tolerance,
|
||||
const float bottomPlaneHeight);
|
||||
|
||||
static bool intersectingWorldOrOthers( const G3D::Array<Primitive*>& primitives,
|
||||
ContactManager& contactManager,
|
||||
const float tolerance,
|
||||
const float bottomPlaneHeight);
|
||||
|
||||
// ToDo::Deprecate Array Version
|
||||
static Extents computeExtents(const G3D::Array<Primitive*>& primitives);
|
||||
|
||||
static Extents computeExtents(const std::vector<PVInstance*>& instances);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
/*
|
||||
// End user tools
|
||||
|
||||
// Drop tool is like a drag tool, except it knows how to cancel itself, and has a different behavior on mouseUp
|
||||
|
||||
*/
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class Workspace;
|
||||
class PartInstance;
|
||||
class PVInstance;
|
||||
|
||||
class DropTool
|
||||
{
|
||||
public:
|
||||
static shared_ptr<MouseCommand> createDropTool(const Vector3& hitWorld,
|
||||
const std::vector<Instance*>& dragInstances,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag,
|
||||
bool suppressPartsAlign = false);
|
||||
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sGameTool;
|
||||
class GameTool : public Named<MouseCommand, sGameTool>
|
||||
{
|
||||
private:
|
||||
std::string cursor;
|
||||
|
||||
bool draggablePart(const PartInstance* part, const Vector3& hitPoint) const;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const {return cursor;}
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
public:
|
||||
GameTool(Workspace* workspace);
|
||||
~GameTool();
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<GameTool>(workspace);}
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sGrabTool;
|
||||
class GrabTool : public Named<MouseCommand, sGrabTool>
|
||||
{
|
||||
private:
|
||||
std::string cursor;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const {return cursor;}
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
public:
|
||||
GrabTool(Workspace* workspace);
|
||||
~GrabTool();
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<GrabTool>(workspace);}
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
#include "Tool/DragUtilities.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class MegaDragger;
|
||||
|
||||
extern const char* const sGroupDragTool;
|
||||
class GroupDragTool : public Named<MouseCommand, sGroupDragTool>
|
||||
{
|
||||
protected:
|
||||
std::auto_ptr<MegaDragger> megaDragger;
|
||||
Vector2 downPoint;
|
||||
bool dragging;
|
||||
Vector3 lastHit;
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
public:
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const {
|
||||
return dragging ? "GrabRotateCursor" : "DragCursor";
|
||||
}
|
||||
|
||||
GroupDragTool( PartInstance* mousePart,
|
||||
const Vector3& hitPointWorld,
|
||||
const PartArray& partArray,
|
||||
Workspace* workspace);
|
||||
|
||||
~GroupDragTool();
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,43 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/GroupDragTool.h"
|
||||
#include "Tool/ICancelableTool.h"
|
||||
#include "Tool/DragUtilities.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class MegaDragger;
|
||||
|
||||
extern const char* const sGroupDropTool;
|
||||
class GroupDropTool
|
||||
: public Named<GroupDragTool, sGroupDropTool>
|
||||
, public ICancelableTool
|
||||
{
|
||||
private:
|
||||
typedef Named<GroupDragTool, sGroupDropTool> Super;
|
||||
public:
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
///*override*/ void onMouseDelta(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/const std::string getCursorName() const {return MouseCommand::isAdvArrowToolEnabled() ? "advClosed-hand" : "DropCursor";}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// ICancelableTool
|
||||
//
|
||||
/*override*/ shared_ptr<MouseCommand> onCancelOperation();
|
||||
|
||||
GroupDropTool( PartInstance* mousePart,
|
||||
const PartArray& partArray,
|
||||
Workspace* workspace,
|
||||
bool suppressPartsAlign = false);
|
||||
|
||||
~GroupDropTool();
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sHammerTool;
|
||||
class HammerTool : public Named<MouseCommand, sHammerTool>
|
||||
{
|
||||
private:
|
||||
typedef Named<MouseCommand, sHammerTool> Super;
|
||||
shared_ptr<PartInstance> hammerPart;
|
||||
|
||||
/*ovverrid*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
/*override*/ const std::string getCursorName() const;
|
||||
|
||||
public:
|
||||
HammerTool(Workspace* workspace);
|
||||
~HammerTool();
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<HammerTool>(workspace);}
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,18 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX
|
||||
{
|
||||
class ICancelableTool
|
||||
{
|
||||
|
||||
public:
|
||||
virtual shared_ptr<MouseCommand> onCancelOperation() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //namespace
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
#include "Tool/LuaDragger.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class PartInstance;
|
||||
|
||||
extern const char* const sLuaDragTool;
|
||||
class LuaDragTool : public Named<MouseCommand, sLuaDragTool>
|
||||
{
|
||||
private:
|
||||
boost::shared_ptr<LuaDragger> luaDragger;
|
||||
boost::weak_ptr<Instance> selectIfNoDrag;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const;
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
public:
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
LuaDragTool( PartInstance* mousePart,
|
||||
const Vector3& hitPointWorld,
|
||||
const std::vector<weak_ptr<PartInstance> >& partArray,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag);
|
||||
|
||||
~LuaDragTool();
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,73 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8Tree/Instance.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class Joint;
|
||||
class PartInstance;
|
||||
class ContactManager;
|
||||
class RunDragger;
|
||||
|
||||
extern const char* const sLuaDragger;
|
||||
|
||||
class LuaDragger
|
||||
: public DescribedCreatable<LuaDragger, Instance, sLuaDragger>
|
||||
{
|
||||
private:
|
||||
typedef enum {NO_PARTS, MOUSE_DOWN, DRAGGING, MOUSE_UP_DRAGGED, MOUSE_UP_NO_DRAG} DragPhase;
|
||||
DragPhase dragPhase;
|
||||
|
||||
std::vector<shared_ptr<Joint> > jointsIMade;
|
||||
weak_ptr<PartInstance> rootPart;
|
||||
std::auto_ptr<RunDragger> runDragger; // only if we have one part
|
||||
|
||||
float hitPointHeight;
|
||||
|
||||
typedef std::vector<weak_ptr<PartInstance> > WeakParts;
|
||||
WeakParts dragParts;
|
||||
weak_ptr<PartInstance> mousePart;
|
||||
Vector3 pointOnMousePart;
|
||||
|
||||
void tryStartDragging(const RbxRay& unitMouseRay);
|
||||
void startDragging();
|
||||
void doDrag(const RbxRay& unitMouseRay);
|
||||
bool getSnapHitPoint(PartInstance* part, const RbxRay& unitMouseRay, Vector3& hitPoint);
|
||||
ContactManager& getContactManager(PartInstance* partInstance);
|
||||
|
||||
const float breakFreeDistance() {return 1.5f;} // distance in studs at the mouse down point before movement
|
||||
|
||||
void addPart(shared_ptr<const Instance> part);
|
||||
/*override*/ bool askSetParent(const Instance* instance) const { return false; }
|
||||
|
||||
public:
|
||||
LuaDragger();
|
||||
~LuaDragger();
|
||||
|
||||
void mouseDownPublic(shared_ptr<Instance> _mousePart,
|
||||
Vector3 _pointOnMousePart,
|
||||
shared_ptr<const Instances> _dragParts);
|
||||
|
||||
void mouseDown( shared_ptr<PartInstance> _mousePart,
|
||||
const Vector3& _pointOnMousePart,
|
||||
const std::vector<weak_ptr<PartInstance> > _dragParts);
|
||||
|
||||
void mouseMove(RbxRay mouseRay); // inefficient, but easier to have just one version
|
||||
|
||||
void mouseUp();
|
||||
|
||||
const WeakParts& getParts() {return dragParts;}
|
||||
|
||||
void rotateOnSnapFace(Vector3::Axis, const Matrix3& rotMatrix);
|
||||
void axisRotate(Vector3::Axis axis);
|
||||
|
||||
bool isDragging() const {return dragPhase == DRAGGING;}
|
||||
|
||||
bool didDrag() const {return dragPhase == MOUSE_UP_DRAGGED;}
|
||||
|
||||
void alignPartToGrid( void );
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,100 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Util/Object.h"
|
||||
#include "Util/G3DCore.h"
|
||||
#include "Tool/DragUtilities.h"
|
||||
#include "Tool/DragTypes.h"
|
||||
//#include <vector>
|
||||
|
||||
namespace RBX {
|
||||
class Primitive;
|
||||
class PVInstance;
|
||||
class PartInstance;
|
||||
class RootInstance;
|
||||
class ContactManager;
|
||||
class InputObject;
|
||||
|
||||
class MegaDragger
|
||||
{
|
||||
private:
|
||||
weak_ptr<PartInstance> mousePart;
|
||||
PartArray dragParts;
|
||||
|
||||
// Join/unjoin stuff
|
||||
bool joined;
|
||||
DRAG::JoinType joinType;
|
||||
|
||||
// Workspace stuff
|
||||
RootInstance* rootInstance;
|
||||
ContactManager& contactManager;
|
||||
|
||||
bool moveSafePlaceAlongLine(const Vector3& tryDrag);
|
||||
|
||||
public:
|
||||
MegaDragger(PartInstance* mousePartPtr,
|
||||
const std::vector<PVInstance*>& pvInstances,
|
||||
RootInstance* rootInstance,
|
||||
DRAG::JoinType joinType = DRAG::UNJOIN_JOIN);
|
||||
|
||||
MegaDragger(PartInstance* mousePartPtr,
|
||||
const PartArray& partArray,
|
||||
RootInstance* rootInstance,
|
||||
DRAG::JoinType joinType = DRAG::UNJOIN_JOIN);
|
||||
|
||||
|
||||
|
||||
~MegaDragger();
|
||||
|
||||
void setToSelection(const Workspace* workspace);
|
||||
|
||||
// Drag cycle - start, continue (before every move), finish
|
||||
void startDragging();
|
||||
void continueDragging(); // every drag step/move/idle
|
||||
void finishDragging();
|
||||
|
||||
// Inquiry
|
||||
bool mousePartAlive();
|
||||
bool anyDragPartAlive();
|
||||
|
||||
// Part Dragger
|
||||
weak_ptr<PartInstance> getMousePart() {
|
||||
RBXASSERT(!mousePart.expired());
|
||||
return mousePart;
|
||||
}
|
||||
|
||||
// Group Dragger
|
||||
void alignAndCleanParts();
|
||||
void cleanParts();
|
||||
Vector3 hitObjectOrPlane(const shared_ptr<InputObject>& inputObject); // ignore the drag parts - find a hit point with the world
|
||||
Vector3 safeMoveYDrop(const Vector3& tryDrag); // 1. Go directly to new location, 2. Moves down until collision - if necessary, moves up
|
||||
|
||||
// Axis Tools
|
||||
Vector3 safeMoveAlongLine(const Vector3& tryDrag, bool snapToWorld = true);
|
||||
Vector3 safeRotateAlongLine(const Vector3& tryDrag);
|
||||
|
||||
Vector3 safeMoveAlongLine2(const Vector3& tryDrag, bool& out_isCollided);
|
||||
Vector3 safeRotateAlongLine2(const Vector3& tryDrag, const float &angle);
|
||||
|
||||
Vector3 safeMoveToMinimumHeight(float yValue);
|
||||
|
||||
/**
|
||||
* Rotates drag parts
|
||||
* @param rotMatrix rotation matrix to apply
|
||||
* @param respectCollisions if true then check for collision will be done
|
||||
in case of collisions no rotation will be performed
|
||||
* @return Matrix after rotation
|
||||
*/
|
||||
Matrix3 rotateDragParts(const Matrix3& rotMatrix, bool respectCollisions);
|
||||
|
||||
bool moveAlongLine(const Vector3& tryDrag);
|
||||
|
||||
// General Placement
|
||||
Vector3 safeMoveNoDrop(const Vector3& tryDrag); // On initial collision - moves up
|
||||
bool safeRotate(const Matrix3& rotMatrix);
|
||||
void removeParts();
|
||||
private:
|
||||
void getPartsForDrag(G3D::Array<Primitive*>& primitives);
|
||||
};
|
||||
} // namespace
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/ToolsArrow.h"
|
||||
#include "AppDraw/HandleType.h"
|
||||
#include "Util/NormalId.h"
|
||||
#include "Tool/DragTypes.h"
|
||||
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sMoveResizeJoinTool;
|
||||
class MoveResizeJoinTool : public Named<AdvArrowTool, sMoveResizeJoinTool>
|
||||
{
|
||||
private:
|
||||
typedef Named<AdvArrowTool, sMoveResizeJoinTool> Super;
|
||||
void findTargetPV(const shared_ptr<InputObject>& inputObject);
|
||||
void capturedDrag(float axisDelta);
|
||||
float moveIncrement(void);
|
||||
int smallGridBoxesPerStud(void);
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
static weak_ptr<PVInstance> scalingPart;
|
||||
|
||||
protected:
|
||||
|
||||
bool resizeFloat(shared_ptr<PartInstance> part, NormalId localNormalId, float amount, bool checkIntersection);
|
||||
bool advResizeImpl(shared_ptr<PartInstance> part, NormalId localNormalId, float amount, bool checkIntersection);
|
||||
|
||||
// IAdornable
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
|
||||
// Tool
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const {return cursor;}
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void setCursor(std::string newCursor) {cursor = newCursor;}
|
||||
|
||||
weak_ptr<PVInstance> targetPV;
|
||||
|
||||
bool overHandle;
|
||||
NormalId localNormalId;
|
||||
Vector3 hitPointGrid;
|
||||
Vector2int16 down;
|
||||
int movePerp;
|
||||
bool dragging;
|
||||
CoordinateFrame origPartPosition;
|
||||
Vector3 origPartSize;
|
||||
std::string cursor;
|
||||
float origPartTransparency;
|
||||
|
||||
public:
|
||||
MoveResizeJoinTool(Workspace* workspace) :
|
||||
Named<AdvArrowTool, sMoveResizeJoinTool>(workspace),
|
||||
overHandle(false),
|
||||
movePerp(0),
|
||||
dragging(false),
|
||||
origPartSize(0.0f, 0.0f, 0.0f),
|
||||
cursor("advCursor-default"),
|
||||
origPartTransparency(0.0f)
|
||||
{}
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<MoveResizeJoinTool>(workspace);}
|
||||
|
||||
static void setSelection(shared_ptr<RBX::Instance> oldSelection, shared_ptr<RBX::Instance> newSelection);
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
namespace Network {
|
||||
class Player;
|
||||
}
|
||||
|
||||
// Super tool - combines click to move, etc.
|
||||
extern const char* const sNewNullTool;
|
||||
class NewNullTool : public Named<MouseCommand, sNewNullTool>
|
||||
{
|
||||
private:
|
||||
typedef Named<MouseCommand, sNewNullTool> Super;
|
||||
std::string cursor;
|
||||
bool hasWaypoint;
|
||||
Vector3 waypoint;
|
||||
|
||||
bool isInFirstPerson();
|
||||
void getIndicatedPart(const shared_ptr<InputObject>& inputObject, const bool& clickEvent,
|
||||
PartInstance** instance, bool* clickable, Vector3* waypoint);
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onRightMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const {return cursor;}
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<NewNullTool>(workspace);}
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject) {
|
||||
releaseCapture();
|
||||
return shared_from(this);
|
||||
}
|
||||
/*override*/ shared_ptr<MouseCommand> onRightMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// IAdornable
|
||||
//
|
||||
/*override*/ bool shouldRender3dAdorn() const {return true;}
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
|
||||
void updateClickDetectorHover(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
public:
|
||||
NewNullTool(Workspace* workspace);
|
||||
~NewNullTool();
|
||||
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class RunDragger;
|
||||
class MegaDragger;
|
||||
|
||||
extern const char* const sPartDragTool;
|
||||
class PartDragTool : public Named<MouseCommand, sPartDragTool>
|
||||
{
|
||||
private:
|
||||
typedef Named<MouseCommand, sPartDragTool> Super;
|
||||
protected:
|
||||
std::auto_ptr<RunDragger> runDragger; // does snapping
|
||||
std::auto_ptr<MegaDragger> megaDragger; // does join / unJoin
|
||||
shared_ptr<Instance> selectIfNoDrag;
|
||||
Vector2 downPoint;
|
||||
bool dragging;
|
||||
Vector3 hitWorld;
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
public:
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseDelta(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
/*override*/ const std::string getCursorName() const {
|
||||
return dragging ? "GrabRotateCursor" : "DragCursor";
|
||||
}
|
||||
|
||||
PartDragTool( PartInstance* mousePart,
|
||||
const Vector3& hitPointWorld,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag);
|
||||
|
||||
~PartDragTool();
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/PartDragTool.h"
|
||||
#include "Tool/ICancelableTool.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sPartDropTool;
|
||||
class PartDropTool
|
||||
: public Named<PartDragTool, sPartDropTool>
|
||||
, public ICancelableTool
|
||||
{
|
||||
private:
|
||||
typedef Named<PartDragTool, sPartDropTool> Super;
|
||||
public:
|
||||
/////////////////////////////////////////////////////////
|
||||
// MouseCommand
|
||||
//
|
||||
/*override*/ void onMouseDelta(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
///*override*/ MouseCommand* onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/const std::string getCursorName() const {return MouseCommand::isAdvArrowToolEnabled() ? "advClosed-hand" : "DropCursor";}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// ICancelableTool
|
||||
//
|
||||
/*override*/ shared_ptr<MouseCommand> onCancelOperation();
|
||||
|
||||
PartDropTool( PartInstance* mousePart,
|
||||
const Vector3& hitPointWorld,
|
||||
Workspace* workspace,
|
||||
shared_ptr<Instance> selectIfNoDrag);
|
||||
|
||||
~PartDropTool();
|
||||
|
||||
private:
|
||||
Vector3 hitLocal;
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Tool/ToolsArrow.h"
|
||||
#include "AppDraw/HandleType.h"
|
||||
#include "Util/NormalId.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
extern const char* const sResizeTool;
|
||||
|
||||
class ResizeTool : public Named<ArrowToolBase, sResizeTool>
|
||||
{
|
||||
|
||||
private:
|
||||
typedef Named<ArrowToolBase, sResizeTool> Super;
|
||||
void findTargetPV(const shared_ptr<InputObject>& inputObject);
|
||||
void capturedDrag(int axisDelta);
|
||||
|
||||
/*override*/ bool drawConnectors() const {return true;} // default mouse command no draw connectors
|
||||
|
||||
protected:
|
||||
// IAdornable
|
||||
/*override*/ void render3dAdorn(Adorn* adorn);
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
|
||||
// Tool
|
||||
/*override*/ void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ const std::string getCursorName() const;
|
||||
|
||||
weak_ptr<PVInstance> targetPV;
|
||||
|
||||
bool overHandle;
|
||||
NormalId localNormalId;
|
||||
Vector3 hitPointGrid;
|
||||
Vector2int16 down;
|
||||
int moveAxis;
|
||||
int movePerp;
|
||||
int moveIncrement;
|
||||
|
||||
public:
|
||||
ResizeTool(Workspace* workspace) :
|
||||
Named<ArrowToolBase, sResizeTool>(workspace),
|
||||
overHandle(false),
|
||||
moveAxis(0),
|
||||
movePerp(0)
|
||||
{}
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<ResizeTool>(workspace);}
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
@@ -0,0 +1,113 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
//#include "V8World/Joint.h"
|
||||
#include "V8World/Contact.h"
|
||||
#include "Util/Object.h"
|
||||
#include "Util/G3DCore.h"
|
||||
#include "Util/NormalId.h"
|
||||
#include <vector>
|
||||
#include "Tool/DragTypes.h"
|
||||
#include "AppDraw/DrawAdorn.h"
|
||||
#include "GfxBase/Adorn.h"
|
||||
#include "GfxBase/IAdornable.h"
|
||||
|
||||
|
||||
|
||||
namespace RBX {
|
||||
class Primitive;
|
||||
class PartInstance;
|
||||
class Workspace;
|
||||
|
||||
class RunDragger : public IAdornable
|
||||
{
|
||||
private:
|
||||
class SnapInfo {
|
||||
public:
|
||||
Primitive* snap;
|
||||
size_t mySurfaceId;
|
||||
Vector3 hitWorld;
|
||||
Vector3 lastHitWorld;
|
||||
Vector3 lastDragSnap;
|
||||
SnapInfo()
|
||||
: snap(NULL)
|
||||
, mySurfaceId((size_t)-1)
|
||||
, hitWorld(Vector3::inf())
|
||||
, lastHitWorld(Vector3::inf())
|
||||
, lastDragSnap(Vector3::inf())
|
||||
{}
|
||||
void updateHitFromSurface(const RbxRay& mouseRay);
|
||||
void updateSurfaceFromHit();
|
||||
float hitOutsideExtents();
|
||||
};
|
||||
|
||||
// Initialized
|
||||
// Poor man's version - ultimately, change all internally to shared_ptr's
|
||||
weak_ptr<PartInstance> dragPart;
|
||||
weak_ptr<PartInstance> snapPart;
|
||||
|
||||
Workspace* workspace;
|
||||
Primitive* drag;
|
||||
Vector3 dragPointLocal;
|
||||
Matrix3 dragOriginalRotation;
|
||||
|
||||
// Carry forward data
|
||||
SnapInfo snapInfo;
|
||||
|
||||
// Set on every snap() call
|
||||
RbxRay mouseRay;
|
||||
|
||||
// Computed every snap() call
|
||||
NormalId dragSurface; // computed
|
||||
// Angled surface testing...
|
||||
size_t myDragSurfaceId; // computed
|
||||
Vector3 dragHitLocal; // computed
|
||||
|
||||
// modes
|
||||
|
||||
SnapInfo createSnapSurface(Primitive* snap, G3D::Array<size_t>* ignore = NULL);
|
||||
bool moveDragPart();
|
||||
bool snapDragPart();
|
||||
void snapRotatePart();
|
||||
|
||||
void findSafeY();
|
||||
bool notTried(Primitive* check, const G3D::Array<Primitive*>& tried);
|
||||
bool adjacent(Primitive* p0, Primitive* p1);
|
||||
SnapInfo rayHitsPart(const G3D::Array<Primitive*>& triedSnap, bool forceAdjacent);
|
||||
SnapInfo bestProximatePart(const G3D::Array<Primitive*>& triedSnap,
|
||||
Contact::ProximityTest proximityTest);
|
||||
bool fallOffEdge();
|
||||
bool fallOffPart(bool& snapped);
|
||||
bool colliding();
|
||||
bool rayHitsCloserPart();
|
||||
bool tooCloseToCamera();
|
||||
|
||||
SnapInfo findSnap(const G3D::Array<Primitive*>& triedSnap);
|
||||
void findNoSnapPosition(const CoordinateFrame& original);
|
||||
|
||||
void snapInfoFromSnapPart();
|
||||
void snapPartFromSnapInfo();
|
||||
|
||||
public:
|
||||
RunDragger();
|
||||
~RunDragger();
|
||||
void init( Workspace* _workspace,
|
||||
weak_ptr<PartInstance> _dragPart,
|
||||
const Vector3& _dragPointWorld);
|
||||
void initLocal( Workspace* _workspace,
|
||||
weak_ptr<PartInstance> _dragPart,
|
||||
const Vector3& _dragPointLocal);
|
||||
|
||||
bool snap(const RbxRay& mouseRay);
|
||||
|
||||
void rotatePartAboutSnapFaceAxis( Vector3::Axis axis, const float& angleInRads );
|
||||
void rotatePart90DegAboutSnapFaceAxis( Vector3::Axis axis );
|
||||
CoordinateFrame getSnapSurfaceCoord();
|
||||
|
||||
// Note: these static functions will NOT update dragOriginalRotation
|
||||
static void turnUpright(PartInstance* part);
|
||||
static void rotatePart(PartInstance* part);
|
||||
static void tiltPart(PartInstance* part, const CoordinateFrame& camera);
|
||||
};
|
||||
} // namespace
|
||||
@@ -0,0 +1,161 @@
|
||||
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "V8DataModel/MouseCommand.h"
|
||||
#include "V8DataModel/ManualJointHelper.h"
|
||||
|
||||
namespace RBX {
|
||||
|
||||
class PartInstance;
|
||||
class Decal;
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ARROW
|
||||
|
||||
#define STUDIO_CAMERA_CONTROL_SHORTCUTS 1
|
||||
|
||||
class ArrowToolBase : public MouseCommand
|
||||
{
|
||||
private:
|
||||
|
||||
typedef MouseCommand Super;
|
||||
|
||||
bool altKeyDown;
|
||||
|
||||
protected:
|
||||
|
||||
Decal* findDecal(PartInstance* p, const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
virtual void onMouseIdle(const shared_ptr<InputObject>& inputObject);
|
||||
virtual void onMouseHover(const shared_ptr<InputObject>& inputObject);
|
||||
virtual shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
virtual const std::string getCursorName() const;
|
||||
virtual shared_ptr<MouseCommand> onPeekKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
virtual void render3dAdorn(Adorn* adorn);
|
||||
|
||||
void renderHoverOver(Adorn* adorn,bool drillDownOnly = true);
|
||||
|
||||
PartInstance* overInstance;
|
||||
|
||||
public:
|
||||
|
||||
ArrowToolBase(Workspace* workspace)
|
||||
: MouseCommand(workspace),
|
||||
overInstance(NULL),
|
||||
altKeyDown(false)
|
||||
{
|
||||
FASTLOG1(FLog::MouseCommandLifetime, "ArrowTool created: %p", this);
|
||||
}
|
||||
|
||||
virtual ~ArrowToolBase()
|
||||
{
|
||||
FASTLOG1(FLog::MouseCommandLifetime, "ArrowTool destroyed: %p", this);
|
||||
}
|
||||
|
||||
static bool showDraggerGrid;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ADVANCED ARROW (parent class for all advanced mouse manipulation
|
||||
|
||||
class AdvArrowToolBase : public ArrowToolBase
|
||||
{
|
||||
private:
|
||||
ManualJointHelper manualJointHelper;
|
||||
typedef ArrowToolBase Super;
|
||||
protected:
|
||||
typedef std::map<boost::weak_ptr<RBX::PartInstance>, float> PartsTransparencyCollection;
|
||||
static PartsTransparencyCollection originalPartsTransparency;
|
||||
public:
|
||||
AdvArrowToolBase(Workspace* workspace) : ArrowToolBase(workspace), manualJointHelper(workspace)
|
||||
{}
|
||||
virtual ~AdvArrowToolBase() {}
|
||||
|
||||
enum JointCreationMode
|
||||
{
|
||||
WELD_ALL = 0,
|
||||
SURFACE_JOIN_ONLY = 1,
|
||||
NO_JOIN = 2
|
||||
};
|
||||
|
||||
virtual shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
virtual void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
virtual shared_ptr<MouseCommand> onMouseUp(const shared_ptr<InputObject>& inputObject);
|
||||
virtual const std::string getCursorName() const;
|
||||
shared_ptr<MouseCommand> onKeyDown(const shared_ptr<InputObject>& inputObject);
|
||||
|
||||
void determineManualJointConditions(void);
|
||||
|
||||
static DRAG::DraggerGridMode advGridMode;
|
||||
static bool advManualJointMode;
|
||||
static DRAG::ManualJointType advManualJointType;
|
||||
static bool advManipInProgress;
|
||||
|
||||
static bool advCollisionCheckMode;
|
||||
static bool advLocalTranslationMode;
|
||||
static bool advLocalRotationMode;
|
||||
static bool advCreateJointsMode;
|
||||
|
||||
static void restoreSavedPartsTransparency();
|
||||
static void savePartTransparency(shared_ptr<PartInstance> part);
|
||||
|
||||
static AdvArrowToolBase::JointCreationMode getJointCreationMode();
|
||||
|
||||
virtual void getSelectedTargetPrimitives(std::vector<Primitive*>& targetPrims) {}
|
||||
virtual void setCursor(std::string cursor) {}
|
||||
};
|
||||
|
||||
extern const char* const sAdvArrowTool;
|
||||
class AdvArrowTool : public Named<AdvArrowToolBase, sAdvArrowTool>
|
||||
{
|
||||
public:
|
||||
AdvArrowTool(Workspace* workspace) : Named<AdvArrowToolBase, sAdvArrowTool>(workspace)
|
||||
{
|
||||
}
|
||||
|
||||
/*override*/ shared_ptr<MouseCommand> isSticky() const {return Creatable<MouseCommand>::create<AdvArrowTool>(workspace);}
|
||||
|
||||
virtual void setCursor(std::string cursor) {}
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BOX SELECT
|
||||
|
||||
extern const char* const sBoxSelectCommand;
|
||||
class BoxSelectCommand : public Named<MouseCommand, sBoxSelectCommand>
|
||||
{
|
||||
private:
|
||||
typedef Named<MouseCommand, sBoxSelectCommand> Super;
|
||||
ServiceClient<Selection> selection;
|
||||
bool reverseSelecting;
|
||||
Vector2int16 mouseDownView;
|
||||
Vector2int16 mouseCurrentView;
|
||||
std::set< shared_ptr<Instance> > previousItemsInBox;
|
||||
|
||||
void getMouseInstances(std::set< shared_ptr<Instance> >& instances,
|
||||
const shared_ptr<InputObject>& inputObject,
|
||||
const Rect2D& selectBox, const Camera* camera,
|
||||
Instance* currentInstance);
|
||||
|
||||
void selectAnd(const std::set< shared_ptr<Instance> >& newItemsInBox);
|
||||
|
||||
void selectReverse(const std::set< shared_ptr<Instance> >& newItemsInBox);
|
||||
|
||||
public:
|
||||
/*override*/ shared_ptr<MouseCommand> onMouseDown(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void onMouseMove(const shared_ptr<InputObject>& inputObject);
|
||||
/*override*/ void render2d(Adorn* adorn);
|
||||
|
||||
BoxSelectCommand(Workspace* workspace);
|
||||
~BoxSelectCommand();
|
||||
};
|
||||
|
||||
} // namespace RBX
|
||||
Reference in New Issue
Block a user