Skip to content

Commit

Permalink
Merge pull request #5 from fwilleke80/new-features
Browse files Browse the repository at this point in the history
Merge new-features
  • Loading branch information
fwilleke80 authored May 22, 2017
2 parents 93d73c6 + 8e812c7 commit 3a2119a
Show file tree
Hide file tree
Showing 8 changed files with 583 additions and 541 deletions.
6 changes: 3 additions & 3 deletions FlockModifier_R16.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
01BA96D31E9D815700E8F37F /* FlockModifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlockModifier.cpp; sourceTree = "<group>"; };
01BA96D41E9D815700E8F37F /* FlockRepeller.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlockRepeller.cpp; sourceTree = "<group>"; };
01BA96D51E9D815700E8F37F /* FlockTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlockTarget.cpp; sourceTree = "<group>"; };
A08C5CDEA3A66833397B0000 /* FlockModifier_R16.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = FlockModifier_R16.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
A08C5CDEA3A66833397B0000 /* FlockModifier.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = FlockModifier.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
A0A668333900000000000000 /* debugbase.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = debugbase.xcconfig; path = ../../frameworks/settings/debugbase.xcconfig; sourceTree = SOURCE_ROOT; };
A0A668333900000000050000 /* releasebase.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = releasebase.xcconfig; path = ../../frameworks/settings/releasebase.xcconfig; sourceTree = SOURCE_ROOT; };
A0A6683339F470FF41020000 /* cinema.framework.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cinema.framework.xcodeproj; path = ../../frameworks/cinema.framework/project/cinema.framework.xcodeproj; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -106,7 +106,7 @@
A0A668333900000000230000 /* products */ = {
isa = PBXGroup;
children = (
A08C5CDEA3A66833397B0000 /* FlockModifier_R16.dylib */,
A08C5CDEA3A66833397B0000 /* FlockModifier.dylib */,
);
name = products;
sourceTree = "<group>";
Expand Down Expand Up @@ -162,7 +162,7 @@
);
name = FlockModifier;
productName = cinema4dsdk;
productReference = A08C5CDEA3A66833397B0000 /* FlockModifier_R16.dylib */;
productReference = A08C5CDEA3A66833397B0000 /* FlockModifier.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
/* End PBXNativeTarget section */
Expand Down
5 changes: 5 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.7.5
- Fixed bug: "Dead" boids that don't move
- Lots of internal optimizations
- Code style

0.7.1
- Only internal changes
- Lazy initialization for GeRayCollider
Expand Down
201 changes: 106 additions & 95 deletions source/helpers.h
Original file line number Diff line number Diff line change
@@ -1,95 +1,106 @@
#ifndef _FLOCKHELPERS_H_
#define _FLOCKHELPERS_H_


#define ID_OFLOCKMODIFIER 1029168
#define ID_OFLOCKREPELLER 1029184
#define ID_OFLOCKTARGET 1029185


#define COLOR_FLOCKTARGET Vector(0.5, 1.0, 0.5)
#define COLOR_FLOCKREPELLER Vector(1.0, 0.3, 0.3)

enum RULEFLAGS
{
RULEFLAGS_NONE = 0,
RULEFLAGS_CENTER = (1<<0),
RULEFLAGS_NEIGHBORDIST = (1<<1),
RULEFLAGS_MATCHVELO = (1<<2),
RULEFLAGS_TARGET = (1<<3),
RULEFLAGS_LEVELFLIGHT = (1<<4),
RULEFLAGS_AVOIDGEO = (1<<5),
RULEFLAGS_TURBULENCE = (1<<6),
RULEFLAGS_SPEEDLIMIT = (1<<7),
RULEFLAGS_REPELL = (1<<8)
} ENUM_END_FLAGS(RULEFLAGS);


struct TargetData
{
Float32 _weight;
Float32 _radius;
Bool _infinite;
Vector _position;

TargetData() :
_weight(0.0),
_radius(0.0),
_infinite(false),
_position(0.0)
{ }

TargetData(Float32 weight, Float32 radius, Bool infinite, const Vector &position) :
_weight(weight), _radius(radius), _infinite(infinite), _position(position)
{ }
};


struct RepellerData
{
Float32 _weight;
Float32 _radius;
Vector _position;

RepellerData() :
_weight(0.0),
_radius(0.0),
_position(0.0)
{ }

RepellerData(Float32 weight, Float32 radius, const Vector &position) :
_weight(weight), _radius(radius), _position(position)
{ }
};


inline void DrawSphere(BaseDraw* bd, Float32 radius)
{
if (!bd)
return;

Matrix mc;
Vector v(DC);

mc.Scale(radius);
bd->DrawCircle(mc);
v = mc.v3; mc.v3 = mc.v2; mc.v2 = v;
bd->DrawCircle(mc);
v = mc.v1; mc.v1 = mc.v3; mc.v3 = v;
bd->DrawCircle(mc);
}


inline void Draw3DCross(BaseDraw* bd, Float32 length)
{
if (!bd) return;

Matrix mc;
Vector v(DC);

bd->DrawLine(Vector(0.0, length, 0.0), Vector(0.0, -length, 0.0), 0);
bd->DrawLine(Vector(length, 0.0, 0.0), Vector(-length, 0.0, 0.0), 0);
bd->DrawLine(Vector(0.0, 0.0, length), Vector(0.0, 0.0, -length), 0);
}

#endif
#ifndef FLOCKHELPERS_H__
#define FLOCKHELPERS_H__


const Int32 ID_OFLOCKMODIFIER = 1029168;
const Int32 ID_OFLOCKREPELLER = 1029184;
const Int32 ID_OFLOCKTARGET = 1029185;

const Vector COLOR_FLOCKTARGET(0.5, 1.0, 0.5);
const Vector COLOR_FLOCKREPELLER(1.0, 0.3, 0.3);


/// Flags to indicate which rules are active
enum RULEFLAGS
{
RULEFLAGS_NONE = 0,
RULEFLAGS_CENTER = (1<<0),
RULEFLAGS_NEIGHBORDIST = (1<<1),
RULEFLAGS_MATCHVELO = (1<<2),
RULEFLAGS_TARGET = (1<<3),
RULEFLAGS_LEVELFLIGHT = (1<<4),
RULEFLAGS_AVOIDGEO = (1<<5),
RULEFLAGS_TURBULENCE = (1<<6),
RULEFLAGS_SPEEDLIMIT = (1<<7),
RULEFLAGS_REPELL = (1<<8)
} ENUM_END_FLAGS(RULEFLAGS);


/// Data for a FlockTarget
struct TargetData
{
Float _weight; ///< Weight of this target
Float _radius; ///< Radius of this target
Float _radiusI; ///< Inverted _radius (for performance reasons)
Bool _infinite; ///< Is target radius infinite?
Vector _position; ///< Global position of target

TargetData() :
_weight(0.0),
_radius(0.0),
_infinite(false),
_position(0.0)
{ }

TargetData(Float weight, Float radius, Bool infinite, const Vector &position) :
_weight(weight),
_radius(radius),
_infinite(infinite),
_position(position)
{ }
};


/// Data for a FlockRepeller
struct RepellerData
{
Float _weight; ///< Weight of this repeller
Float _radius; ///< Radius of this repeller
Float _radiusI; ///< Inverted _radius (for performance reasons)
Vector _position; ///< Global position of repeller

RepellerData() :
_weight(0.0),
_radius(0.0),
_position(0.0)
{ }

RepellerData(Float weight, Float radius, const Vector &position) :
_weight(weight),
_radius(radius),
_position(position)
{ }
};


inline void DrawSphere(BaseDraw *bd, Float radius)
{
if (!bd)
return;

Matrix mc;
Vector v(DC);

mc.Scale(radius);
bd->DrawCircle(mc);
v = mc.v3; mc.v3 = mc.v2; mc.v2 = v;
bd->DrawCircle(mc);
v = mc.v1; mc.v1 = mc.v3; mc.v3 = v;
bd->DrawCircle(mc);
}


inline void Draw3DCross(BaseDraw *bd, Float length)
{
if (!bd)
return;

Matrix mc;
Vector v(DC);

bd->DrawLine(Vector(0.0, length, 0.0), Vector(0.0, -length, 0.0), 0);
bd->DrawLine(Vector(length, 0.0, 0.0), Vector(-length, 0.0, 0.0), 0);
bd->DrawLine(Vector(0.0, 0.0, length), Vector(0.0, 0.0, -length), 0);
}

#endif // FLOCKHELPERS_H__
75 changes: 38 additions & 37 deletions source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
#include "c4d.h"
#include "main.h"


#define PLUGIN_VERSION String("0.7")


Bool PluginStart()
{
GePrint("FlockModifier " + PLUGIN_VERSION);

if (!RegisterFlockModifier())
return false;
if (!RegisterFlockTarget())
return false;
if (!RegisterFlockRepeller())
return false;

return true;
}

void PluginEnd()
{ }

Bool PluginMessage(Int32 id, void *data)
{
switch (id)
{
case C4DPL_INIT_SYS:
return resource.Init(); // don't start plugin without resource

case C4DMSG_PRIORITY:
return true;
}

return false;
}
#include "c4d.h"
#include "main.h"


#define PLUGIN_VERSION String("FlockModifier 0.7.5")


Bool PluginStart()
{
GePrint(PLUGIN_VERSION);

if (!RegisterFlockModifier())
return false;
if (!RegisterFlockTarget())
return false;
if (!RegisterFlockRepeller())
return false;

return true;
}

void PluginEnd()
{
}

Bool PluginMessage(Int32 id, void *data)
{
switch (id)
{
case C4DPL_INIT_SYS:
return resource.Init(); // don't start plugin without resource

case C4DMSG_PRIORITY:
return true;
}

return false;
}
6 changes: 3 additions & 3 deletions source/main.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef _MAIN_H
#define _MAIN_H
#ifndef MAIN_H__
#define MAIN_H__

#include "c4d.h"

Bool RegisterFlockModifier();
Bool RegisterFlockTarget();
Bool RegisterFlockRepeller();

#endif
#endif // MAIN_H__
Loading

0 comments on commit 3a2119a

Please sign in to comment.